Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post

    Coding in & out of <php ?>

    It seems to work, but do you think it's bad form to code in & out of php like this.....

    PHP Code:
    <?php
    if (== 1) {
    ?> // See we close off

    1 IS equal to one!

    <?php

    } else {

    // Hmmmmmm?

    }

    ?>
    What I'm getting @ is still having the if statement open when we close the PHP tags & then start playing around with again after re-opening the PHP tags.

  • #2
    New Coder
    Join Date
    Sep 2004
    Location
    Minnesota, USA
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It just becomes hard to manage in large scripts but theres nothing wrong with it.
    ribbed.us
    ---
    To err is human, to moo bovine.

  • #3
    Regular Coder
    Join Date
    Jan 2004
    Location
    London, UK
    Posts
    234
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I suppose as long as you correctly indent all of your code, it is acceptable and you can manage it.

    Personally, I find it good practice to echo everything within <?php ?> tags, especially when echoing variables within that string.
    Dave

  • #4
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    Thanks for the responses!

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    i usualy only close the php tag and continue on to html, if im working with a large section of html like a table with forms in it and such, or a large body of content.
    If I'm postin here, I NEED YOUR HELP!!

  • #6
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    I've done it this way in the past, and still do to some extent, but in general if it's more than about 10 - 25 lines of HTML, I'll make an include file or function call to handle it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •