|
Posted by Andrew Poelstra on 08/28/06 14:29
Erwin Moller <too_long_address@spamyourself.com> writes:
> Hot cat wrote:
>
>> Howdy all,
>>
>> I just installed php 5 in fedora core 4 and have just written a the first
>> scrip[t that comes in the "man php" (echo "hello world") from the command
>> line.
>>
>> I tried to execute
>> #!/bin/php
>> <?php
>> print ("hello world");
>> ?>
>
>
> When you say you 'installed php' does that mean you set up PHP so it is
> intergrated in apache?
> Because the example you give is CGI-like call to PHP.
> Not many use PHP that way. I am even uncertain if that still works..
>
1) More people use PHP in this way than do web-style.
> So unless you have some exotic setup for some reason, start using PHP via
> your browser.
>
2) Why would he do that? If you were writing a perl script or an awk
script, would you insist he run that in his browser?
> A typical PHP file does NOT contain the bash instruction #!/bin/php.
> It starts like this:
True; it's often easier to type
php myscript.php
But if you have permissions set up correctly, it's easier to just have
the pound-bang at the top of your file.
> <?php
> phpinfo();
> ?>
>
But that's going to spit out a bunch of HTML; all the OP wants is a
"Hello World" program.
> Or if you call it via commandline:
> /pathtophp/php myTest.php
>
PHP is almost always installed in user $PATH. There's no need for the
/pathtophp/.
>> I get bash errors and it won't run.
>> Same when I tried to place a few simple "hello worlds" in a piece
>> of html that I \itried to run on Friefox. Whats the story do I have to
>> fiddle with php.ini, install a plug in for Friefox?
>>
What specific bash errors? You need to
1) Make sure you've got the PHP path right (type "type php").
2) Make sure you're script has execute permissions (type
"chmod +x myscript.php").
3) Add a newline to that print statement; your output could be
buffered, and it's more portable to add a newline to guarantee
that it displays. (That, and without a newline your prompt will
should up right after it on the same line.)
--
Andrew Poelstra <http://www.wpsoftware.net/projects>
To reach me by email, use `apoelstra' at the above domain.
"Do BOTH ends of the cable need to be plugged in?" -Anon.
[Back to original message]
|