How to define and call function inside if () condition in PHP

1 Answer

0 votes
$n = true;

if ($n) 
{
  function f()
  {
    echo "call function f()";
  }
}

if ($n) f();


/*
run:

call function f()

*/

 



answered Jun 20, 2016 by avibootz

Related questions

2 answers 204 views
204 views asked Jun 29, 2016 by avibootz
1 answer 107 views
1 answer 133 views
1 answer 153 views
1 answer 139 views
...