PHP Trim inside function -


i have following simple php script:

<?php      function generate($test_var, trim($test_var2)) {         echo $test_var2;     }      generate('value 1', ' value2');  ?> 

it's giving following error:

php parse error:  syntax error, unexpected '(', expecting '&' or t_variable  in ** on line 3 

i can't figure out why trim can't used in context.

you can't call function inside argument list of definition of function*. perhaps meant this:

function generate($test_var, $test_var2) {     $test_var2 = trim($test_var2);     echo $test_var2; } 

* note can use array language construct when declaring default value of parameter, although isn't function.

further reading


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -