Displaying 1-10 of 37 results.
Resolved: PHP fopen fwrite tab tabulation
posted by admin on April 18, 2017
I have code, where I create file and write string in that file

$string = "Some text \t any text";
$handle = fopen($filename, 'w');
fwrite($handle, $string);

Output as same as I try to create

Some text \t any text
Read more
Resolved: PHP fopen fwrite new line
posted by admin on April 18, 2017
I have code, where I create file and write string in that file

$string = "Some text \n any text \r\n more text \n\r";
$handle = fopen($filename, 'w');
fwrite($handle, $string);

Output as same as I try create

$string = "Some text \n any text \r\n more text \n\r";

How to write text in file with new line?Read more
Resolved: PHP check time 00:00:00 from datetime
posted by admin on November 21, 2016
I have datetime from MySQL db in format Y:m:d H:i:s like

2014-11-02 02:04:05
2014-11-02 00:00:00
etc ...

I want to check, if time from datetime equal "00:00:00", then return or echo only date.

2014-11-02 02:04:05
Read more
Wiki: PHP intval - value to int conversationwiki
posted by admin on November 7, 2016
intval — Возвращает целое значение переменной

int intval ( mixed $var [, int $base = 10 ] )

Возвращает целое значение переменной var, используя указанное основание системы исчисления base для преобразования (по умолчанию основание равно 10). intval() нельзя использовать с объектами, попытка это сделать вызовет ошибку уровня E_NOTICE и вернет значение 1.
Список параметров
  • var - Скалярное значение для конвертации в целое
  • base - Основание системы исчисления для преобразования

Если base равно 0, основание системы исчисления определяется форматом параметра var:
  • если строка включает префикс "0x" (или "0X"), основание выбирается равным 16 (шестнадцатеричным);
  • иначе, если строка начинается с "0", основание равно 8 (восьмеричное);
  • иначе, основание выбирается равным 10 (десятеричным).

Возвращаемые значения
Целое значение переменной var в случае успеха, или 0 в случае неудачи. Для пустых массивов возвращается 0, для непустых возвращается 1.

Максимальное значение зависит от операционной системы. В 32-х битных системах максимальное знаковое целое лежит в диапазоне от -2147483648 до 2147483647. Так, например, в такой системе, intval('1000000000000') вернет 2147483647. Максимальное знаковое целое значение для 64-х битных систем - 9223372036854775807.

Для строк функция скорее всего вернет 0, хотя это зависит от первого символа в строке. Применяются общие правила преобразований в целые.

echo intval(42); // 42
echo intval(4.2); // 4
echo intval('42'); // 42
echo intval('+42'); // 42
echo intval('-42'); // -42
echo intval(042); // 34
echo intval('042'); // 42
echo intval(1e10); // 1410065408
echo intval('1e10'); // 1
echo intval(0x1A); // 26
echo intval(42000000); // 42000000
echo intval(420000000000000000000); // 0
echo intval('420000000000000000000'); // 2147483647
echo intval(42, 8); // 42
echo intval('42', 8); // 34
echo intval(array()); // 0
echo intval(array('foo', 'bar')); // 1
Read more
Resolved: PHP echo link content in page
posted by admin on October 26, 2016
I am working on website and in locale and want to show in my page part of code from live server.

Read more
Resolved: PHP datetime to russian user friendly format converting. Дата и время на русский на дружественный вид
posted by admin on October 12, 2016
I have datetime from databse MySQL, in format
2016-10-10 12:34:33

By PHP datetime formats I can have string like this
07 October 2016, 04:11, Friday

But I want the3 same output, but in russian
07 Октября 2016, 04:11, ПятницаRead more
Resolved: How to clear browser cache when re-uploading image with same filename, in php?
posted by admin on June 18, 2016
I have a listing of items, that also contains an image thumbnail. Sometimes I need to change the thumbnail image, but keep the filename the same. Is there a way to force the browser to download the newly uploaded image, instead of grabbing one from the browser cache?

This is very pertinent when people update their avatars, which causes confusion for some users, who keep seeing their old avatar, until they clear the browser cache, or restart the browser.Read more
Resolved: PHP filesize MB/KB conversion
posted by admin on June 18, 2016
How can I convert the output of PHP's filesize() function to a nice format with MegaBytes, KiloBytes etc?

  • if the size is less than 1 MB, show the size in KB
  • if it's between 1 MB - 1 GB show it in MB
  • [*] if it's larger - in GBRead more
    Resolved: Parse error: syntax error, unexpected '[', expecting ')'
    posted by admin on June 3, 2016
    I have error in oscarotero Embed APP.Read more
    Resolved: error :should not be called statically, assuming $this from incompatible context. only on my machine
    posted by admin on June 3, 2016
    My team members wrote the model function calls in the controller statically such as:

    $data = ModelName::functionName($param);

    while it should be called dynamically such as:

    $model = new Model();
    $data = $model->functionName($param);

    mostly all the calls are made statically. the code is working on the server and on their local machines except for mine. And the static calls are too many to fix without rewriting huge code base.

    I always update my project via composer. My php version is 5.4.

    anyone might know what this is about?Read more