By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,404 Members | 2,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,404 IT Pros & Developers. It's quick & easy.

It appears that <?php ... ?> is not portable. If this is true, why do so many scripts use it?

P: n/a
I'm new to PHP.

Evidently my ISP's server does not recognize <?php ... ?>, but it does
recognize <script language="php"... </script>, which would imply
that <?php ... ?is not portable.

If in fact <?php ... ?is not portable, why are so many PHP scripts
using it?

May 28 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On May 28, 10:14 am, Michael <MichaelDMcDonn...@yahoo.comwrote:
I'm new to PHP.

Evidently my ISP's server does not recognize <?php ... ?>, but it does
recognize <script language="php"... </script>, which would imply
that <?php ... ?is not portable.

If in fact <?php ... ?is not portable, why are so many PHP scripts
using it?
Hmm, never heard of that. Do you have a documentation page that the
ISP has provided explaining this (and maybe why...)?

In general, portability of scripts means that most other servers out
there have at least a basic parser hook into your code (using <?php ?>
tags, or <?asp ?for ASP, etc...). This is MORE portable than using
short tags (such as <? ?>).

Imagine you are a parser (maybe with an Italian accent, just for fun).
What do you do if:

<? ?>

??? Could be ASP, could be PHP, could be xml or any other number of
denoted, parseable scripting entities on a page. <?php says "This is
PHP, as long as you understand it (with a PHP parser). Ignore
otherwise."

If an ISP manually renders <?php ?useless, that's an ISP position. I
can't imagine why they would have done this, as anybody who would want
to use their service for their PHP support would then have to change
all their code pages to reflect the new code tags, which are not
standard and in no way portable.

May 28 '07 #2

P: n/a
Michael kirjoitti:
I'm new to PHP.

Evidently my ISP's server does not recognize <?php ... ?>, but it does
recognize <script language="php"... </script>, which would imply
that <?php ... ?is not portable.

If in fact <?php ... ?is not portable, why are so many PHP scripts
using it?
From php.net:
******************
Example 10.2. PHP Opening and Closing Tags
1. <?php echo 'if you want to serve XHTML or XML documents, do like
this'; ?>

2. <script language="php">
echo 'some editors (like FrontPage) don\'t
like processing instructions';
</script>

3. <? echo 'this is the simplest, an SGML processing instruction'; ?>
<?= expression ?This is a shortcut for "<? echo expression ?>"

4. <% echo 'You may optionally use ASP-style tags'; %>
<%= $variable; # This is a shortcut for "<% echo . . ." %>

While the tags seen in examples one and two are both always available,
example one is the most commonly used, and recommended, of the two.
******************
From http://www.php.net/manual/en/language.basic-syntax.php

I must say the server configuration at you ISP is something quite odd,
since it distinctly says above that <?php ?is _always_ available.
Short open tags and asp-style tags are configurable. But to answer your
question: so many scripts use <?php ?simply because it is officially
recommended.

You might want to check with your ISP to see what the fuck have they
done to break such a fundamental issue and why have they've chosen to do so.

--
Ra*********@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
May 28 '07 #3

P: n/a

"Michael" <Mi***************@yahoo.comwrote in message
news:11*********************@x35g2000prf.googlegro ups.com...
I'm new to PHP.

Evidently my ISP's server does not recognize <?php ... ?>, but it does
recognize <script language="php"... </script>, which would imply
that <?php ... ?is not portable.

If in fact <?php ... ?is not portable, why are so many PHP scripts
using it?
if you trying that and it doesn't work then chances are there is no php
parser on the server or your doing somethign wrong. Make sure your ISP
supports php first... or since you can use the html tag maybe the parser is
not setup right or something else...

also you have to name the ext php to use have the parser parse it..

if you do

test.html,

<?php echo "hello"; ?>

then that is not php code but html text...

so you have to put it as test.php.

May 28 '07 #4

P: n/a
Michael wrote:
If in fact <?php ... ?is not portable, why are so many PHP scripts
using it?
First, do you think that "<? ?>" or "<script language=php>", or "<% %>" are
portable??

Second, the "<?php ?>" syntax is the *recommended* one. See
http://www.php.net/manual/en/language.basic-syntax.php

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Más vale ser cobarde un minuto, que muerto todo el resto de la vida.
May 28 '07 #5

P: n/a
On May 28, 8:37 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.comwrote:
"Michael" <MichaelDMcDonn...@yahoo.comwrote in message

news:11*********************@x35g2000prf.googlegro ups.com...
I'm new to PHP.
Evidently my ISP's server does not recognize <?php ... ?>, but it does
recognize <script language="php"... </script>, which would imply
that <?php ... ?is not portable.
If in fact <?php ... ?is not portable, why are so many PHP scripts
using it?

if you trying that and it doesn't work then chances are there is no php
parser on the server or your doing somethign wrong. Make sure your ISP
supports php first... or since you can use the html tag maybe the parser is
not setup right or something else...

also you have to name the ext php to use have the parser parse it..

if you do

test.html,

<?php echo "hello"; ?>

then that is not php code but html text...

so you have to put it as test.php.
=============================
Thanks to all of you for your help. I'll check and make sure that the
test I ran used proper syntax. I believe the server that I'm connected
to is Windows based, but I assume that that should make no difference.

May 28 '07 #6

P: n/a
On May 28, 5:44 pm, Michael <MichaelDMcDonn...@yahoo.comwrote:
On May 28, 8:37 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.comwrote:
"Michael" <MichaelDMcDonn...@yahoo.comwrote in message
news:11*********************@x35g2000prf.googlegro ups.com...
I'm new to PHP.
Evidently my ISP's server does not recognize <?php ... ?>, but it does
recognize <script language="php"... </script>, which would imply
that <?php ... ?is not portable.
If in fact <?php ... ?is not portable, why are so many PHP scripts
using it?
if you trying that and it doesn't work then chances are there is no php
parser on the server or your doing somethign wrong. Make sure your ISP
supports php first... or since you can use the html tag maybe the parser is
not setup right or something else...
also you have to name the ext php to use have the parser parse it..
if you do
test.html,
<?php echo "hello"; ?>
then that is not php code but html text...
so you have to put it as test.php.

=============================
Thanks to all of you for your help. I'll check and make sure that the
test I ran used proper syntax. I believe the server that I'm connected
to is Windows based, but I assume that that should make no difference.
No, that shouldn't make any difference, fortunately Microsoft doesn't
make PHP nor Apache. <?php #code# ?is definitely something ANY php
parser should understand. It takes guts and wits to reconfigure a web
server in such way it doesn't recognise this syntax :)

May 28 '07 #7

P: n/a
On May 28, 11:35 am, Darko <darko.maksimo...@gmail.comwrote:
No, that shouldn't make any difference, fortunately Microsoft doesn't
make PHP nor Apache. <?php #code# ?is definitely something ANY php
parser should understand. It takes guts and wits to reconfigure a web
server in such way it doesn't recognise this syntax :)
If somebody HAS done this (web host), I assume they've built or
borrowed an entity parser (probably in .NET, Ruby, Python) that
provides simple entity parsing based on script blocks, which they (I
assume) then put the contents of into a call to a command-line
instance of PHP. In this way, I assume someone could extend php into a
codebase that does not natively understand PHP. If the folks building
this type of PHP extension needed it quickly/did not understand about
<?php and why ignoring it is bad (destroys portability of code), then
I think, unless they have REALLY good reasons for doing so, I'd find
another web host.

May 28 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.