WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Functions.php - Can I use a single PHP tag for ALL my functions ? (2 posts)

  1. riversatile
    Member
    Posted 1 year ago #

    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 ...
  2. linux4me2
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic