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

This is a discussion on It appears that <?php ... ?> is not portable. If this is true, why do so many scripts use it? within the PHP Language forums, part of the PHP Programming Forums category; I'm new to PHP. Evidently my ISP's server does not recognize <?php ... ?>, but it does recognize &...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-28-2007
Michael
 
Posts: n/a
Default It appears that <?php ... ?> is not portable. If this is true, why do so many scripts use it?

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?

Reply With Quote
  #2 (permalink)  
Old 05-28-2007
farrishj@gmail.com
 
Posts: n/a
Default Re: It appears that <?php ... ?> is not portable. If this is true, why do so many scripts use it?

On May 28, 10:14 am, Michael <MichaelDMcDonn...@yahoo.com> wrote:
> 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.

Reply With Quote
  #3 (permalink)  
Old 05-28-2007
Jon Slaughter
 
Posts: n/a
Default Re: It appears that <?php ... ?> is not portable. If this is true, why do so many scripts use it?


"Michael" <MichaelDMcDonnell@yahoo.com> wrote in message
news:1180365240.818621.26220@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.



Reply With Quote
  #4 (permalink)  
Old 05-28-2007
Rami Elomaa
 
Posts: n/a
Default Re: It appears that <?php ... ?> is not portable. If this is true,why do so many scripts use it?

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.

--
Rami.Elomaa@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Reply With Quote
  #5 (permalink)  
Old 05-28-2007
Iván Sánchez Ortega
 
Posts: n/a
Default Re: It appears that <?php ... ?> is not portable. If this is true, why do so many scripts use it?

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.
Reply With Quote
  #6 (permalink)  
Old 05-28-2007
Michael
 
Posts: n/a
Default Re: It appears that <?php ... ?> is not portable. If this is true, why do so many scripts use it?

On May 28, 8:37 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.com> wrote:
> "Michael" <MichaelDMcDonn...@yahoo.com> wrote in message
>
> news:1180365240.818621.26220@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.

Reply With Quote
  #7 (permalink)  
Old 05-28-2007
Darko
 
Posts: n/a
Default Re: It appears that <?php ... ?> is not portable. If this is true, why do so many scripts use it?

On May 28, 5:44 pm, Michael <MichaelDMcDonn...@yahoo.com> wrote:
> On May 28, 8:37 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.com> wrote:
>
> > "Michael" <MichaelDMcDonn...@yahoo.com> wrote in message

>
> >news:1180365240.818621.26220@x35g2000prf.googlegr oups.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 :)

Reply With Quote
  #8 (permalink)  
Old 05-28-2007
farrishj@gmail.com
 
Posts: n/a
Default Re: It appears that <?php ... ?> is not portable. If this is true, why do so many scripts use it?

On May 28, 11:35 am, Darko <darko.maksimo...@gmail.com> wrote:
> 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.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:54 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0