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 14 of 14
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post

    Using < and > in PHP

    How to do it? PHP is giving errors when I try to echo it!

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just tried this and it worked just fine:
    PHP Code:
    <body>
    <?php
     
    echo "&lt; and &gt;";
    ?>
    </body>
    Unless I'm misunderstanding.. what errors are you getting?

    Sadiq.

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    As soon as it hist this line..

    PHP Code:
    echo "&lt;form action=\"formmail.cgi\" method=\"post\"&gt;"
    It gives this error:

    Parse error: parse error, expecting `','' or `';''

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's a Javascript error, isn't it? You don't need to use those codes, just use the < and > normally:
    PHP Code:
     echo "<form action=\"formmail.cgi\" method=\"post\">"
    Sadiq.

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    or better still
    PHP Code:
    echo '<form action="formmail.cgi" method="post">'
    Check theline right above the line you posted. probbly missed the ; at the end or so on that line.
    It's a PHP error, by the way.

    <edit>not sure what you are trying to do. Are you trying to send the formtag as html code, or do you want to have it displayed on screen?</edit>
    Last edited by raf; 05-27-2004 at 12:03 AM.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #6
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    Yes.. my first code is correct.. I need the <> displayed on screen so I need to use &lt; and &gt;

  • #7
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok... so you solved it or no?

    Sadiq.

  • #8
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    No, still problems.

  • #9
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,051
    Thanks
    10
    Thanked 94 Times in 92 Posts
    did you try Raf's code ? and check as suggested the lines above the reported error ? , as sad69 says unless you are outputting javascript you don't need to use &lt;&gt; etc
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #10
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why not htmlentities(); ?
    PHP Code:
    <?php
        $entities 
    = array('>','<');

        
    $gt htmlentities($entities[0]);
        
    $lt htmlentities($entities[1]);
        
        echo 
    $lt."b".$gt."bold".$lt."/b".$gt;
        
    // outputs <b>bold</b>
    ?>
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #11
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cypics,

    PHP Code:
    echo '<form action="formmail.cgi" method="post">'
    will output the htmlcode you need for a formtag. if you'd look at the pagesource inside your browser, then you'd see
    <form action="formmail.cgi" method="post">
    It does not produce any visible output when the page is loaded.

    If you use
    PHP Code:
    echo htmlentities('<form action="formmail.cgi" method="post">'); 
    then you wiil see
    <form action="formmail.cgi" method="post">
    on screen as visible output. If you look at the source in your browser, then you'll see
    &lt;form name=&quot;registration&quot; action=&quot;ffff&quot; method=&quot;post&quot;&gt;

    hope this clears it up for you.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #12
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    Ok, I feel so stupid... the error it was getting was because there was non-escpaped quotes on the line above & I definately thought it was referring to the line below since it was the first line with these tags in them... I always make sure to escape my quotes but I copied this code from another file & forgot to escape them lol

    Anyway.... I used htmlentities & have it all working!

    Thanks for all the help guys!

  • #13
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're welcome.
    I must be spychic
    Quote Originally Posted by raf
    Check theline right above the line you posted. probbly missed the ; at the end or so on that line.
    It's a PHP error, by the way.
    It's just like my boss says : why doesn't everyone just do what i say so we'll at least get something done around here!
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #14
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    lol


  •  

    Posting Permissions

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