• Resolved Riversatile

    (@riversatile)


    Is it better to use a single <?php tag for all my functions and close with ?> at the end

    <? php
    
    function example1 () {
    ???? do something
    }
    example1 ();
    
    function example2 () {
    ???? do something
    }
    example2 ();
    
    etc ...
    ?>

    Or use a <?php tag for each function and close each function with ?>

    <? php
    function example1 () {
    ???? do something
    }
    example1 ();
    ?>
    
    <? php
    function example2 () {
    ???? do something
    }
    example2 ();
    ?>
    
    etc ...
Viewing 1 replies (of 1 total)
  • I think it’s best in a PHP-only file to use only one set of opening and closing tags. It makes the code more readable and less prone to errors.

    The multiple sets of opening and closing tags are more useful for scripts that include both PHP and HTML or other language output.

Viewing 1 replies (of 1 total)
  • The topic ‘Functions.php – Can I use a single PHP tag for ALL my functions ?’ is closed to new replies.