broken up function


#1

Is it legal to start a function then jump out of PHP, to jump back in and finish the function? I don’t think so but can’t remember it clearly.


#2

Like to jump out and do what?

I believe you can call a function from a function. Certainly if you define a another function from within the function (nested functions) you can, but it can create other issues.


#3

like

<?php
function something ()
{
   echo 'Here we do something';
?>
<p>Here we are outside PHP in the HTML fields</p>
<?php 
   echo 'Here we are back inside PHP';
}
?>
<p>HTML text before</p>
<?php something(); ?>
<p>HTML text after</p>

I guess I am just being really lazy - cause I can take that code and just run it and see what happens… ran it in PHP 5 and apache 2 - and it works.


#4

I was going to suggest that. Nonetheless, it should work anyway. Anything out side the PHP tags would just still be treated like part of the function.


#5

My example works - but found out how it can’t be done also. It happens when you are working with classes… here is the link. Basically you can do it inside a function definition - but not inside a class definition.

Knew I saw it someplace.