troubleshooting Question

Inserted functions in php syntax

Avatar of Bitlab
BitlabFlag for United States of America asked on
5 Comments1 Solution257 ViewsLast Modified:
Hello Experts.

Is the following syntax LEGAL in php 5.1+ ?


function top()
      function inside($y)
            echo ($y+2);
      echo $x.' ';


//outputs:41 7
      Note, we don't ask works this code or not, it works.
      Note, we need some prove like reference to documentation, or to cow path in solid php packages.
      "Cow path" by definition is a practice of multiple programmers which is impossible to neglect by language developers.

      Here is the reason why this question.
      We are working with application which requires to write code in templates.
      Templates are php files, but they can be parts of some unknown code, so perhaps code inside of function body or class body.
    We need to isolate our local variables in "inside" function.
      We are running php 5.1 and higher.
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros