SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php doesn't display content in browser

    Hi,

    I'm new to PHP and since I'm setting up a website using Joomla 2.5, I need some basic understanding of PHP. But when I run the following code, from a book I'm using as a intro text, nothing is displayed on Firefox (version 18).

    Code:
    <html>
    <head><title>PHP says hello</title></head>
    <body>
    <b>
    <?php
    echo "Hello, World!";
    ?>
    </b>
    </body> 
    </html>
    I've checked out phpinfo() to the extent of my limited understanding and I can't see anything obviously wrong.

    Any help would be much appreciated

  2. #2
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't mention that I saved the file as html. I changed this to php but no text shown on opening the file in Firefox.

  3. #3
    SitePoint Evangelist
    Join Date
    May 2003
    Posts
    595
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make the file a .php file, and add the 2 'php' lines ..

    PHP Code:
    <?php
    ?>
    <html>
    <head><title>PHP says hello</title></head>
    <body>
    <b>
    <?php
    echo "Hello, World!";
    ?>
    </b>
    </body> 
    </html>
    I ran this through php, and it seemed to output what you need (html code).

  4. #4
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Jesoshua,

    I had some success too. I moved the original file over to /var/www directory (localhost) and it ran OK as a php file. I also made the changes you suggested and that worked too. My mistake really was rather obvious when you come to think of it, php obviously works within the server environment.

    Thanks for your help, I appreciate it.

  5. #5
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Jehoshua,

    sorry I mispelt your name

    best regards

    Royt


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
  •