Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi Larry,


It's been a while since I've visited the forums so I hope that all is well with you.


I have a question that you have already answered on page 51 and that is to do with the closing ?>


The context I have is some php code that optionally 'requires' a php function which is the only thing in the .php file being 'required'.


Is there any difference that the .php file which is the function is being optionally 'required' versus just 'required' in the normal code stream?


The php file with the function does have the opening <?php tag but it is being included within a php code stream.  Should I have the opening tag in the function 'include'?


Originally I had the closing ?> in the function code and that worked fine in my development environment, but caused the error message in the production environment.


My development environment is Windows 7 with xampp providing localhost.


Many thanks in anticipation for your advice, or that of any other forum member.


Cheers from Oz.



Link to comment
Share on other sites

  • 3 weeks later...

The simple rules of thumb are:

- In order to have any file execute PHP code, it must put that code after the opening PHP tag

- The last closing PHP tag in a file is optional


So an includable file or an including file can omit the last closing tag (so long as you don't have HTML after it).

Link to comment
Share on other sites


  • Create New...