473,424 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,424 software developers and data experts.

["HTTP_POST"} versus ['HTTP_POST']

I've inherited a huge, rambling site with numerous lines containing
$_SERVER["HTTP_POST"]
php.net says it should be single inverted commas, not double, yet
everything seems to work. As it would be a considerable amount of
work to change everything, can I safely leave things as they are?
TIA.
Jul 7 '07 #1
3 2609
jo*****@hotmail.com kirjoitti:
I've inherited a huge, rambling site with numerous lines containing
$_SERVER["HTTP_POST"]
php.net says it should be single inverted commas, not double, yet
everything seems to work. As it would be a considerable amount of
work to change everything, can I safely leave things as they are?
TIA.
I'm sure you've misinterpreted the manual. The syntax above, with double
quotes is prefectly fine. All it does is that it delimits a string
literal, for this puropuse double quotes and single quotes are just
fine. The reason single quotes is _preferred_ (but not required) is that
in this case it's slightly faster. You see, double quoted strings may
containt php variables that are replaced with the string values of the
variables. Single quoted strings do not have this quality, and that is
the reason they work a little bit faster than double quoted strings.

But like the wise man said: if it works, don't fix it. You can leave it
just like that and be cool with it. I'm sure the possible improvement in
performance that you'd gain from changing each double quote to single
quote is nominal, you'll do nothing but waste your time.

Finally a little example to demonstrate the difference.
<?php

$cat = "Garfield";

echo "That $cat is so funny!"; // Double quotes
// This will print: That Garfield is so funny!
// $cat is changed into its value.

echo 'That $cat is so funny!'; // Single Quotes
// This will print: That $cat is so funny!
// No changes are made, printed literally as it's written.

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

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Jul 7 '07 #2
jo*****@hotmail.com wrote:
I've inherited a huge, rambling site with numerous lines containing
$_SERVER["HTTP_POST"]
php.net says it should be single inverted commas, not double, yet
everything seems to work. As it would be a considerable amount of
work to change everything, can I safely leave things as they are?
TIA.
In this case there is no difference between single and double.

You cannot break anything by changing it to single quotes and it's no
work at all, just do a global replace of one for another.

The only case a replace can break if there is a string like this:

'I am using $_SERVER["HTTP_POST"] variable'

will convert to:

'I am using $_SERVER['HTTP_POST'] variable'

and break the code into syntax error

Roman
Jul 7 '07 #3
On Sat, 07 Jul 2007 11:55:00 +0300, Rami Elomaa
<ra*********@gmail.comwrote:
>jo*****@hotmail.com kirjoitti:
>I've inherited a huge, rambling site with numerous lines containing
$_SERVER["HTTP_POST"]
php.net says it should be single inverted commas, not double, yet
everything seems to work. As it would be a considerable amount of
work to change everything, can I safely leave things as they are?
TIA.

I'm sure you've misinterpreted the manual. The syntax above, with double
quotes is prefectly fine. All it does is that it delimits a string
literal, for this puropuse double quotes and single quotes are just
fine. The reason single quotes is _preferred_ (but not required) is that
in this case it's slightly faster. You see, double quoted strings may
containt php variables that are replaced with the string values of the
variables. Single quoted strings do not have this quality, and that is
the reason they work a little bit faster than double quoted strings.

But like the wise man said: if it works, don't fix it. You can leave it
just like that and be cool with it. I'm sure the possible improvement in
performance that you'd gain from changing each double quote to single
quote is nominal, you'll do nothing but waste your time.

Finally a little example to demonstrate the difference.
<?php

$cat = "Garfield";

echo "That $cat is so funny!"; // Double quotes
// This will print: That Garfield is so funny!
// $cat is changed into its value.

echo 'That $cat is so funny!'; // Single Quotes
// This will print: That $cat is so funny!
// No changes are made, printed literally as it's written.
Thanx to both of you.
Jul 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Dieter Vanderelst | last post by:
Dear all, I'm currently comparing Python versus Perl to use in a project that involved a lot of text processing. I'm trying to determine what the most efficient language would be for our...
33
by: Joshua D. Drake | last post by:
Hello, I think the below just about says it all: http://www.commandprompt.com/images/mammoth_versus_dolphin_500.jpg Sincerely, Joshua Drake
2
by: Andrew Robinson | last post by:
I need to create a shared static field for use within a number of different classes. Which one should I be using or are they all really the same thing? public class Widget { private Widget() {}...
2
by: Jon Lapham | last post by:
I have a table that stores TEXT information. I need query this table to find *exact* matches to the TEXT... no regular expressions, no LIKE queries, etc. The TEXT could be from 1 to 10000+...
0
by: Edmund Green | last post by:
Included below is a minimal web-service implementation to recreate a problem I've encountered in a web service that has methods returning classes with the same local name (but in different...
1
by: Maxwell2006 | last post by:
Hi, How can I disable HttpGet and HttpPost access to my asmx webservice? Thank you,
0
by: Matthew Lock | last post by:
Hello, I am enabling my web service via HttpPost so that a simple Javascript client can access web services by posting with XmlHttpRequest. I have added the following nodes into my web.config to...
4
by: aj | last post by:
DB2 8.2 LUW FP14 Is there any real difference between select blahblahblah... where blah IN (select blah......) versus select blahblahblah... where blah = ANY (select blah.....) versus select...
5
by: Dave | last post by:
I'm writing an app that needs to send info to a client by their specs, m_request= "https://website.com/app?xml=xml_file&xmlString=<?xml version='1.0' encoding='utf-8'...
1
by: miki | last post by:
i m trying to get xml response from httppost, the xml include the char "&" thnks miki
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.