Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
functions.php
#1
The optional theme file functions.php: It starts with 
PHP Code:
<?php if(!defined('IN_GS')){ die... 

but it doesn't have a closing php tag [ ?> ] at the end of the file, after whatever functions ? 
Is that right?
Reply
#2
yeah its fine, some people leave the close php tag out as it prevents errors if whitespace is left after the tag.


From the PHP Manual: The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is helpful when using include() or require(), so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later.Nov 13, 2013
My Github Repos: Github
Website: DigiMute
Reply
#3
Yes, that's right.

The end of the <?php tag is implied by the end of the file. Additionally, not having the closing tag means that there will not be any errors introduced by, for example, a newline after the closing tag.

The 'no closing tag' is considered good practice, as I recall. If I can find a reference, I'll add it.

Edit: @n00dles beat me to it ...
--
Nick.
Reply
#4
Thanks, both.

I tidied the file up by closing the php, got an error, scratched head...
Reply




Users browsing this thread: 1 Guest(s)