Good day.
The point is: there is some variable that receives the address of the picture, which is then processed by the function and returned, but the point is that when the return occurs, the value becomes zero.
Here is the php code:
<?php $img="http/site.ru/1.img"; var_dump($img); function strReplase($imgThe){ $imgUrl=str_replace(".jpg","-150x150.jpg",$imgThe); return $imgUrl; } var_dump(strReplase($img);?> In response, I get:
string(18)"http/site.ru/1.img" null Prompt, please, why value is not transferred from function. The code is not quite alive, so ochepyatki possible somewhere.
And if you put
return var_dump($imgUrl); it will work out
string(18)"http/site.ru/1.img" string(25)"http/site.ru/1-150x150.img" null that is, the function processes the data.
Then asked to lay out this function.
At the moment on the site (of course, this is a test for verification) I have placed the following code here:
function srtReplace($img){ $imgUrl=str_replace(".jpg","-150x150.jpg",$img); return $ImgUrl;} $theOneImg="http://site.ru/one.jpg"; $oneThumb=srtReplace($theOneImg); var_dump($oneThumb); The result is null.