0
<?php
function outLala() {
?>
  lala
<?php   
}
?>

the result of this php file is a blank page instead of a page with text "lala".

if i change the code as

<?php
function outLala() {}
?>
  lala
<?php   
{}
?>

the result of this php file is a page with text "lala".

does it mean that the php interpreter will parse the code inside the open and the close tag, and if it finds a function(or something else) is not properly terminated, the interpreter will think the content following the close tag is part of the function?

2
  • 2
    Well... lala is inside the outLala() function definition, so... I guess it gets output whenever the function is called, but I've never seen anyone write PHP code like that. Commented Oct 19, 2013 at 10:11
  • 1
    Wordpress themes are not generally to be considered PHP best practice. Commented Oct 19, 2013 at 10:14

2 Answers 2

3

This is valid PHP, but you don't call the function. Add

outLala();

at the bottom.

Sign up to request clarification or add additional context in comments.

Comments

2

You must call function outLala. Example:

<?php
function outLala() {
?>
  lala
<?php   
}
outLala();
?>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.