LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-07-2007, 09:11 AM   #1
Instantly
Member
 
Registered: Dec 2004
Posts: 78

Rep: Reputation: 15
PHP newbie


so I just installed everything to run PHP, and I started with the Hello World tut.

I pasted
Code:
<html>
<body>

<?php
echo "Hello World";
?>

</body>
</html>
to a kate and saved it test.php on desktop
when I opened it, it asked me to either open it (with kate) or save it (as if I am downloading the page)

on the other hand, if I made a php file and put it in /var/www/
it works perfectly.

my question: should it only work in /var/www/ ??? is it normal like this?
if not , why is this happening?
 
Old 07-07-2007, 09:24 AM   #2
zaichik
Member
 
Registered: May 2004
Location: Iowa USA
Distribution: CentOS
Posts: 419

Rep: Reputation: 30
The script needs to be "opened" in such a way that your PHP-enabled web server is handing the script off to the PHP engine and being parsed, and then being served by the web server. If you just double-click on it, you are not parsing it. So when you open it by pointing a browser to http://localhost/test.php that is happening. I'm not clear on how you are "opening" it from your desktop, but however it is you are doing it, it's not getting passed to the PHP/Zend engine.
 
Old 07-07-2007, 12:35 PM   #3
Instantly
Member
 
Registered: Dec 2004
Posts: 78

Original Poster
Rep: Reputation: 15
when I type the http://localhost/test.php in firefox, it opens normally
but if I saved the file and click on it to open it... it wont open (it would act as if Im downloading it)

what should I do?
 
Old 07-07-2007, 02:26 PM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Nothing? It's supposed to be like that. As zaichik said above, the script needs to be parsed. You could run the interpreter on the command line, e.g. "php test.php" and you'll see the output.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Newbie william001 Programming 3 03-22-2007 10:52 AM
Newbie PHP question sleepisforwimps Programming 2 08-28-2005 04:06 AM
Newbie needs help with PHP code mclard Programming 7 12-09-2004 12:50 PM
PHP newbie question jacksmash Programming 20 11-22-2003 11:52 AM
Newbie and PHP david63 Linux - Newbie 3 05-08-2003 03:18 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration