Results 1 to 8 of 8
  1. #1
    Apprentice gursimran_2006's Avatar
    Join Date
    Sep 2006
    Location
    In ur Dreams
    Posts
    92

    Lightbulb HTML Code in PHP

    How 2 add HTML Code In PHP Webpage
    Friends, Plzzz Visit my website
    http://www.gursimran.c-o.in/
    add ur link to my Database and signup it is Free!
    Plzzz do not forget click on Advertisements, coz i need $$
    Cheers,
    Gursimran.

  2. #2
    String Phreak mediator's Avatar
    Join Date
    Mar 2005
    Location
    In ur Evil Mind!
    Posts
    2,458

    Default Re: HTML Code in PHP

    Thats easy! U have 2 options
    Let me give u an example with <a href...> thing!

    1. : Parting the Php block
    Code:
    <?php
    {
    //code...php block initiated
    ?>
    <a href="mediator_is_great.htm">meds</a>
    <?php
    //code php block completed
    }
    ?>
    2. : In one go!
    Code:
    <?php
    $link="mediator_is_great.html";
    $name="meds";
    echo "<a href=\"$link\">$name</a>";
    ?>
    Like wise to mark something bold we have
    Code:
    <?php
    echo "<b>mediator is cool</b>";
    ?>
    Ur Problem Solved!
    Last edited by mediator; 18-10-2006 at 09:12 PM.
    Bad Bad server.....No candy for u!

  3. #3
    Alpha Geek
    Join Date
    Aug 2006
    Posts
    570

    Default Re: HTML Code in PHP

    Just use it after any php code end (IMO), google further

  4. #4
    In Pursuit of "Happyness" kalpik's Avatar
    Join Date
    May 2005
    Location
    New Delhi
    Posts
    3,417

    Default Re: HTML Code in PHP

    Mediator has given the correct solution, so no need to google!

  5. #5
    eWebGuru ahref's Avatar
    Join Date
    Mar 2006
    Location
    Dehradun
    Posts
    427

    Default Re: HTML Code in PHP

    Although mediator has explained clearly. Let me add my two cents
    Server will treat everything outside <?php ?> tags as html.
    If you want to add any html tag in php script then use eithter echo or print command like
    <?php
    print "<h1>Hello World</h1>";
    ?>
    Windows and linux hosting at http://www.ewebguru.com
    Get $50 per blog post PM me for details.

  6. #6
    Human Spambot tuxfan's Avatar
    Join Date
    Feb 2004
    Location
    Mumbai
    Posts
    2,653

    Default Re: HTML Code in PHP

    My further 1 cent in addition to ahref's 2 cents

    Its not the server that treats PHP, its the PHP interpreter that does the job!! Here's the over-simplified sequence.
    1. A browser sends a request for a file to the server.
    2. If its .php file, Apache calls in PHP interpreter for help and hands over the file to it.
    3. PHP interpreter goes thru the file and processes everything thats within <?php and ?> tags. However, it doesn't do anything to the code thats outside those tags.
    4. Apache once again takes over the output give by the interpreter and hands it over to the browser which is dumb enough to understand only HTML and Javascript.
    5. If the browser is IE, it will render even a W3 standard compliant page erroneously. If the browser is not IE, it is more likely that the page is rendered correctly

    I would also like to point out that PHP can be used anywhere on the page whether it be <head> or <title> or whatever!! For example, based on certain criterion, it can even me made to select a differnt external CSS files or change the title of the page. Here's a small simple example.

    PHP Code:
    <html>
      <head>
        <title>
          <?php
            $myid 
    $_GET["identity"];
            if (
    $myid == "one")
              print(
    "This is the my favourite page tite");
             else
              print(
    "This is the default page title");
          
    ?>
        </title>
      </head>
      <body>
      </body>
    </html>
    So start thinking a little differently. You can use break-away from static code anywhere with just the <?php and ?> tags. All that you need is .php extension to the file.
    Last edited by tuxfan; 19-10-2006 at 11:42 AM.
    :: Free hosting and free domain names available in special cases. Conditions apply ::

  7. #7
    "The Cake is a Lie!!" [xubz]'s Avatar
    Join Date
    Oct 2006
    Posts
    471

    Default Re: HTML Code in PHP

    Guys, its better if you use PHP BBCode Tag..

    PHP Code:
    <html>
      <body>
        <b>
        <?php
           $a
    =1;
           
    $b=2;
           if(
    $a==$b) {
              echo 
    "Bull5hit!";
           } else {
              die(
    "Yay!");
           }
         
    ?>
         </b>
      </body>
    </html>
    [xubz] ● http://xubz.com/
    [steam_id] ● http://steamcommunity.com/id/xubz

  8. #8
    Human Spambot tuxfan's Avatar
    Join Date
    Feb 2004
    Location
    Mumbai
    Posts
    2,653

    Default Re: HTML Code in PHP

    Quote Originally Posted by subbzzz
    Guys, its better if you use PHP BBCode Tag..
    At first, I didn't understand what you are saying! But then found out that you are right. You are talking about the php tag for posting in the forum. The tag makes the PHP code more readable on the forum and its nothing to do with the php tag in HTML pages.
    :: Free hosting and free domain names available in special cases. Conditions apply ::

Similar Threads

  1. Html open in new tab code
    By mohityadavx in forum Programming
    Replies: 2
    Last Post: 06-11-2011, 05:34 PM
  2. Replies: 2
    Last Post: 23-12-2006, 07:43 PM
  3. HTML Code problem
    By hailgautam in forum QnA (read only)
    Replies: 4
    Last Post: 24-10-2006, 02:21 PM
  4. HTML code is Off ! ! !
    By ax3 in forum QnA (read only)
    Replies: 5
    Last Post: 18-10-2006, 10:30 AM
  5. Html code for forum
    By himtuna in forum Internet & WWW
    Replies: 7
    Last Post: 19-06-2006, 05:04 PM

Bookmarks

Posting Permissions

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