Page 1 of 1
First PHP ever is not working
Posted: Sat Dec 06, 2014 11:24 pm
by Landslyde
I did an online tutorial that simply embeds PHP in the HTML.
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>Hello PHP, World!</title>
</head>
<body>
<?php
echo 'Hello PHP, World!';
?>
</body>
</html>
I'm using BluFish editor on Linux Mint. When I run the page (index.php - and have also tried it as index.html), it loads on Firefox but shows NOTHING! Just a blank, white page. I've been fighting this all day as I detest having to ask for help...but here I am. I can't figure this out. Any help wld be greatly appreciated.
Landslyde
Re: First PHP ever is not working
Posted: Sat Dec 06, 2014 11:38 pm
by requinix
Does it have Hello PHP, World in the title? What is the URL you're trying? And if you do a View Source of the page, do you see the PHP code?
Re: First PHP ever is not working
Posted: Sat Dec 06, 2014 11:44 pm
by Landslyde
requinix wrote:Does it have Hello PHP, World in the title? What is the URL you're trying? And if you do a View Source of the page, do you see the PHP code?
No. I set the title myself just to make sure that the page was loading.
The URL:
http://devzone.zend.com/4/php-101-part- ... bbit-hole/
I substituted the words. No big deal there.
Yes, when I view the page source, I see the PHP. Also, when I seclect all on the page, the PHP part of the source is highlited. Nothing goes wrong. No errors or anything. It's just that no print shows up on the page after it loads in Firefox.
Re: First PHP ever is not working
Posted: Sun Dec 07, 2014 12:12 am
by requinix
Landslyde wrote:No. I set the title myself just to make sure that the page was loading.
Actually I was asking whether you saw "Hello PHP, World" in the title bar or tab of your browser.
Not the URL of whatever you're learning from. The URL as you're looking at (trying to look at) your PHP script. It should be like "
http://localhost/php101/x1.php" (as they show*) and
not like "file:///var/www/x1.php".
Landslyde wrote:Yes, when I view the page source, I see the PHP.
That means your PHP code isn't being executed. How did you install PHP?
Landslyde wrote:Also, when I seclect all on the page, the PHP part of the source is highlited.
Odd. You shouldn't be able to see it at all, even with a Select All. It should only appear in the page source. But whatever, that's not important.
* That tutorial is from 2004. They include a screenshot of the page in IE 6 (I think). Please see if you can't find something a bit more, you know,
recent.
Re: First PHP ever is not working
Posted: Sun Dec 07, 2014 12:59 am
by Landslyde
URL I see is: file:///home/woogi/Desktop/BlueFish/index.php
I run Linux Mint 17.1...Here's a look at the PHP I have installed on it:
$ php --version
PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
And one more thing: When i run the page as .html, it laods in the browser but shows me nothing. You already know this. However, if i run it using .php extension, Firefox immediately prompts and asks what Firefox should do with this file: inxdex.php. The default action is to open it with my BueFish HTML editor...from which I just came
I'm completely lost here. Something as simple as this is becoming a nightmare quick, fast, and in a hurry.
Any ideas?
UPDATE: I just joined an apache server forum. The login page given is:
http://www.apachelounge.com/login.php
And I can see it. So what in the world am I doing wrong?

Re: First PHP ever is not working
Posted: Sun Dec 07, 2014 4:49 am
by requinix
Landslyde wrote:URL I see is: file:///home/woogi/Desktop/BlueFish/index.php
That's the problem. The URL
must be
http://something. With just file://something you're going to get the file as-is - if your browser knows what to do with it, or else you'll get that download prompt. PHP doesn't get involved anywhere in there.
You need a web server. Like Apache. Take a look at
this tutorial. When that is set up your PHP files will go in /var/www and you'll use a URL like
http://localhost/index.php.
Re: First PHP ever is not working
Posted: Sun Dec 07, 2014 10:29 am
by Landslyde
Yeah. I narrowed it down before I went to bed last night. I have apache2 running on my Linux here, but I think I may have to reinstall it.
Thanks a million for your advice / help. I'll let you know how it goes.
Landslyde
Re: First PHP ever is not working
Posted: Sun Dec 07, 2014 10:34 am
by Celauran
Why would you need to reinstall it? I'd just check that you have all the necessary PHP modules installed. Mint is Debian-based, right? Installing phpMyAdmin should pull in most of the dependencies you need for PHP development (if memory serves).