470,862 Members | 1,835 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,862 developers. It's quick & easy.

php syntax question

Hello. Rank php newbie, here. I just setup my Slack 12 httpd to run php
based on advice I found in Linuxquestions. I finally got it working, but
the prob was not the config, which I had no prob with, but the syntax of a
simple php file. The test.php file given was:

<? phpinfo(); ?>

.....which didn't work. But, fooling around with some other expamples, I
noticed <?php ? syntax instead of just <? ?>. I added the "php":

<?php phpinfo(); ?>

.....and the test file worked just fine. So, what's the deal? Is there a
configuration I can make or does php5 (apache2) always require the "php" in
the tag?

thank you,
nb
Jun 2 '08 #1
5 1125
On Sun, 18 May 2008 21:20:41 +0200, notbob <no****@nothome.comwrote:
Hello. Rank php newbie, here. I just setup my Slack 12 httpd to run php
based on advice I found in Linuxquestions. I finally got it working, but
the prob was not the config, which I had no prob with, but the syntax of
a
simple php file. The test.php file given was:

<? phpinfo(); ?>

....which didn't work. But, fooling around with some other expamples, I
noticed <?php ? syntax instead of just <? ?>. I added the "php":

<?php phpinfo(); ?>

....and the test file worked just fine. So, what's the deal? Is there a
configuration I can make or does php5 (apache2) always require the "php"
in
the tag?
Search the manual for short_open_tags. And rather then enabling it (which
could cause trouble with XML, and make your script not work on a server
with it disabled), just change all your php tags to proper <?php.
--
Rik Wasmus
....spamrun finished
Jun 2 '08 #2
On Sun, 18 May 2008 19:20:41 GMT, notbob wrote:
Hello. Rank php newbie, here. I just setup my Slack 12 httpd to run php
based on advice I found in Linuxquestions. I finally got it working, but
the prob was not the config, which I had no prob with, but the syntax of a
simple php file. The test.php file given was:

<? phpinfo(); ?>

....which didn't work. But, fooling around with some other expamples, I
noticed <?php ? syntax instead of just <? ?>. I added the "php":

<?php phpinfo(); ?>

....and the test file worked just fine. So, what's the deal? Is there a
configuration I can make or does php5 (apache2) always require the "php" in
the tag?
It's the configuration variable short_open_tag in the php.ini file.
Whether you want to turn it on or not is up to you but be aware that if
you're wirting things for placement in an environment where you may not
be in control of the php.ini (such as a hosted space), you may want to
discipline yourself to use the full open tag always.

--
41. Once my power is secure, I will destroy all those pesky time-travel
devices.
--Peter Anspach's list of things to do as an Evil Overlord
Jun 2 '08 #3
On May 18, 12:20 pm, notbob <not...@nothome.comwrote:
....and the test file worked just fine. So, what's the deal? Is there a
configuration I can make or does php5 (apache2) always require the "php" in
the tag?

thank you,
nb
<? ?can be just about any scripting language on a webserver (and if
it is IIS it could very well be ASP).

<?php ?can only be php

Use the longer tags and life will be good, and you will not have to
fix it later (IIRC PHP 6 will require long tags).
Jun 2 '08 #4
On 2008-05-18, Peter H. Coffin <he*****@ninehells.comwrote:
discipline yourself to use the full open tag always.
Thank you, Rik and Peter. I suspected something like that and so will leave
the config option be and use proper php syntax. I've been doing likewise
with html (no <p tags) and have noticed less problems. I'm finding it's
better to take the time up front than spend more time debugging.

nb
Jun 2 '08 #5
On Sun, 18 May 2008 13:00:14 -0700 (PDT), la***@portcommodore.com wrote:
On May 18, 12:20 pm, notbob <not...@nothome.comwrote:
>....and the test file worked just fine. So, what's the deal? Is there a
configuration I can make or does php5 (apache2) always require the "php" in
the tag?

thank you,
nb

<? ?can be just about any scripting language on a webserver (and if
it is IIS it could very well be ASP).

<?php ?can only be php
Indeed, and there's little to nothing that I can think of that would
prevent a (im)properly configured webserver from parsing the same page
for multiple different script languages. It would be ... interesting to
write for if you knew which would be processed first, and a nightmare if
you didn't.

--
When you have a thermic lance, everything looks like hours of fun.
-- Christian Wagner in a.s.r
Jun 2 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

699 posts views Thread by mike420 | last post: by
2 posts views Thread by bor_kev | last post: by
3 posts views Thread by astromog | last post: by
11 posts views Thread by deppy_3 | last post: by
8 posts views Thread by Smithers | last post: by
6 posts views Thread by Daniel | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.