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 300 views
300 views asked Jun 29, 2016 by avibootz
1 answer 206 views
1 answer 214 views
1 answer 238 views
1 answer 214 views
...