<? PHP vs. <?

This is a discussion on <? PHP vs. <? within the PHP forums in Programming Languages category; On Thu, Jan 18, 2001 at 03:14:44PM -0800, Shawn Blaylock wrote: > It's my understanding that whitespace is ignored. I could be wrong here, > though. Whitespace plays a very importend role. Between the opening tag and after a whitespace should follow valid PHP or XML code. There is one exception: <?phpinfo()?> -Egon -- http://www.linuxtag.de/ http://php.net/books.php http://www.concert-band.de/ mailto:linuxtag-subscribe @ php-homepage.de...

Go Back   Application Development Forum > Programming Languages > PHP

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #21  
Old 01-18-2001, 06:25 PM
eschmid+sic@s.netic.de
Guest
 
Default Re: [PHP] <? PHP vs. <?

On Thu, Jan 18, 2001 at 03:14:44PM -0800, Shawn Blaylock wrote:
> It's my understanding that whitespace is ignored. I could be wrong here,
> though.


Whitespace plays a very importend role. Between the opening tag and
after a whitespace should follow valid PHP or XML code. There is one
exception:

<?phpinfo()?>

-Egon

--
http://www.linuxtag.de/
http://php.net/books.php
http://www.concert-band.de/
mailto:linuxtag-subscribe@php-homepage.de
Reply With Quote
  #22  
Old 01-21-2001, 05:03 PM
Brian White
Guest
 
Default XML Processing Instruction ( was " <? PHP vs. <?" )

At 10:50 AM 1/19/12 +0200, Teodor Cimpoesu wrote:

>I was refering to whole story of using `<?' in xml docs.
>
>-- teodor


The "<?"...">" construct comes from SGML/XML - it is called a
"Processing Instruction"(PI). It's general purpose is to allow
application to leave pieces of information in the XML that
aren't strictly part of the content but allow it to help
process it. Classic use of it to put in page formatting
information into content ( pagebreaks, page no's etc ) that is
only relevant to the paper production system.

Part of the problems is that multiple different applications
can use PI's, so they need to be able to tell which ones are
their's - therefore the first thing that should go in a PI
is some kind of indication as to which application requires
it.

Therefore: Always "<?php" is a much better idea than "<?"

Regs

Brian White
-------------------------
Brian White
Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy

http://www.steptwo.com.au/
bwhite@steptwo.com.au

Reply With Quote
  #23  
Old 01-21-2001, 08:40 PM
Romulo Roberto Pereira
Guest
 
Default Re: [PHP] XML Processing Instruction ( was " <? PHP vs. <?" )

If I am not mistaken XML tags needs to be identifed. So <? doesn't mean much
in XML... I like both sintaxes and in my company we only use <? ?>... Maybe
we could vote the use or not of this feature?

Rom
----- Original Message -----
From: Brian White <bwhite@steptwo.com.au>
To: <teo@digiro.net>; <php-general@lists.php.net>
Sent: Sunday, January 21, 2001 5:03 PM
Subject: [php] XML Processing Instruction ( was " <? PHP vs. <?" )


At 10:50 AM 1/19/12 +0200, Teodor Cimpoesu wrote:

>I was refering to whole story of using `<?' in xml docs.
>
>-- teodor


The "<?"...">" construct comes from SGML/XML - it is called a
"Processing Instruction"(PI). It's general purpose is to allow
application to leave pieces of information in the XML that
aren't strictly part of the content but allow it to help
process it. Classic use of it to put in page formatting
information into content ( pagebreaks, page no's etc ) that is
only relevant to the paper production system.

Part of the problems is that multiple different applications
can use PI's, so they need to be able to tell which ones are
their's - therefore the first thing that should go in a PI
is some kind of indication as to which application requires
it.

Therefore: Always "<?php" is a much better idea than "<?"

Regs

Brian White
-------------------------
Brian White
Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy

http://www.steptwo.com.au/
bwhite@steptwo.com.au


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net

Reply With Quote
  #24  
Old 01-21-2001, 08:49 PM
Romulo Roberto Pereira
Guest
 
Default Re: [PHP] XML Processing Instruction ( was " <? PHP vs. <?" )

I forgot to mention that if is PHP the parser (since you are creating PHP
scripts in a server that use PHP as CGI or as a module) this could not be
treated by the parser? I mean, the common XML tag is <?xml version...
Couldn't this be solved in the server side?
----- Original Message -----
From: Brian White <bwhite@steptwo.com.au>
To: <teo@digiro.net>; <php-general@lists.php.net>
Sent: Sunday, January 21, 2001 5:03 PM
Subject: [php] XML Processing Instruction ( was " <? PHP vs. <?" )


At 10:50 AM 1/19/12 +0200, Teodor Cimpoesu wrote:

>I was refering to whole story of using `<?' in xml docs.
>
>-- teodor


The "<?"...">" construct comes from SGML/XML - it is called a
"Processing Instruction"(PI). It's general purpose is to allow
application to leave pieces of information in the XML that
aren't strictly part of the content but allow it to help
process it. Classic use of it to put in page formatting
information into content ( pagebreaks, page no's etc ) that is
only relevant to the paper production system.

Part of the problems is that multiple different applications
can use PI's, so they need to be able to tell which ones are
their's - therefore the first thing that should go in a PI
is some kind of indication as to which application requires
it.

Therefore: Always "<?php" is a much better idea than "<?"

Regs

Brian White
-------------------------
Brian White
Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy

http://www.steptwo.com.au/
bwhite@steptwo.com.au


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net

Reply With Quote
  #25  
Old 01-22-2001, 05:11 AM
Teodor Cimpoesu
Guest
 
Default Re: XML Processing Instruction ( was " <? PHP vs. <?" )



Brian White wrote:
>
> At 10:50 AM 1/19/12 +0200, Teodor Cimpoesu wrote:
>
> >I was refering to whole story of using `<?' in xml docs.

>
> Part of the problems is that multiple different applications
> can use PI's, so they need to be able to tell which ones are
> their's - therefore the first thing that should go in a PI
> is some kind of indication as to which application requires
> it.
>
> Therefore: Always "<?php" is a much better idea than "<?"
>

my follow-up was from an suggest of using <% though
it exists in C, ASP and JSP. We have it in PHP, why not use it?

besides moving a site arround into a configuration you cannot control
I see no other reason.

-- teodor
Reply With Quote
  #26  
Old 01-23-2001, 11:24 AM
Jirka Kosek
Guest
 
Default Re: [PHP] Re: XML Processing Instruction ( was " <? PHP vs. <?" )

Teodor Cimpoesu wrote:

> my follow-up was from an suggest of using <% though
> it exists in C, ASP and JSP. We have it in PHP, why not use it?


Because it is not compatible with XML syntax. Following is incorrect in
XML, because '<' has very restricted usage:

<tag>
<% echo Date("d.m.Y") %>
</tag>

If you use <?php instead, it is perfect XML and you can use any XML
editor or other tool to work with document:

<tag>
<?php echo Date("d.m.Y") ?>
</tag>


-----------------------------------------------------------------
Jirka Kosek
e-mail: jirka@kosek.cz
http://www.kosek.cz
Reply With Quote
  #27  
Old 01-23-2001, 06:58 PM
Brian White
Guest
 
Default Re: XML Processing Instruction ( was " <? PHP vs. <?" )

At 05:24 PM 1/23/01 +0100, Jirka Kosek wrote:
>Teodor Cimpoesu wrote:
> > my follow-up was from an suggest of using <% though
> > it exists in C, ASP and JSP. We have it in PHP, why not use it?

>
>Because it is not compatible with XML syntax.


I agree. The short answer is to the question is "Standards".

There are heaps of tools around for processing data that conforms to the
XML standard - if you keep you documents ( and code script is just a
document ) in XML those tools are available to you.

This is one of the big arguments in favour of XSLT - because it is stored
in XML the argument is that you can manage you XML content documents
and the XSLT code you process it with all with the same set of tools.
This includes editors, document storage, validators, pretty printers etc.

( Note: whether the benefits outweigh the cost in my example are
arguable and I am not going there )



-------------------------
Brian White
Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy

http://www.steptwo.com.au/
bwhite@steptwo.com.au

Reply With Quote
  #28  
Old 03-15-2001, 03:15 PM
Elan
Guest
 
Default Stripping Single Quotes

Hi,

I have a string, "'abc'". How do I convert it to "abc" (i.e. how do I
strip the embedded single quotes) with a minimum of overhead?

(In case you'r wondering: I created the quoted string to store it in
MySQL, now I want to display the same string in a Webpage. Usually the
strings I display do not have embedded single quotes, and I add the
single quotes when I output the string printf("<input type='text'
value='%s'>", $value); That works well enough for strings that don't
already have embedded quotes. But when they do I want to get rid of them
quickly and easily, otherwise I get ...value = ''some value''> and
Netscape doesn't display the value embedded in two single quote
characters).

TIA,

Elan
Reply With Quote
  #29  
Old 03-15-2001, 03:30 PM
CC Zona
Guest
 
Default Re: [PHP] Stripping Single Quotes

In article <3AB122F3.1F28CA27@techscribe.com>, rebol@techscribe.com (Elan)
wrote:

> I have a string, "'abc'". How do I convert it to "abc" (i.e. how do I
> strip the embedded single quotes) with a minimum of overhead?


If there's no chance that the string could also contain legit single-quotes
(such as as an apoostrophe), you can simply use str_replace().

Otherwise, either str_replace() with strpos() -- to search/replace only on
2nd char and 2nd-to-last character -- or good ol' preg_replace() by itself.

--
CC
Reply With Quote
  #30  
Old 03-15-2001, 03:37 PM
Web master
Guest
 
Default Re: [PHP] Stripping Single Quotes

use the following code
$vals=explode("'", "'abc'");
$your_value=$vals[0]; //I am little confused, if it is not working try
index1

Elan wrote:

> Hi,
>
> I have a string, "'abc'". How do I convert it to "abc" (i.e. how do I
> strip the embedded single quotes) with a minimum of overhead?
>
> (In case you'r wondering: I created the quoted string to store it in
> MySQL, now I want to display the same string in a Webpage. Usually the
> strings I display do not have embedded single quotes, and I add the
> single quotes when I output the string printf("<input type='text'
> value='%s'>", $value); That works well enough for strings that don't
> already have embedded quotes. But when they do I want to get rid of them
> quickly and easily, otherwise I get ...value = ''some value''> and
> Netscape doesn't display the value embedded in two single quote
> characters).
>
> TIA,
>
> Elan
>


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 10:47 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.