473,386 Members | 1,698 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,386 software developers and data experts.

How do you interpret single quote embedded in double quote embedded in single quote?

I got the following example from http://www.evolt.org/article/User_Fr...144/index.html
:

echo '<tr><td>First name:</td><td><input type="text" name="first_name"
value="'.htmlspecialchars($_POST['first_name']).'"></td></tr>';

What purpose do the single quotes serve in
value="'.htmlspecialchars($_POST['first_name']).'"

I don't mean the single quotes around first_name. I mean the single
quotes before and after the periods.

Jul 28 '07 #1
2 2856
On Jul 28, 9:33 am, Reporter <TruckSaf...@gmail.comwrote:
I got the following example fromhttp://www.evolt.org/article/User_Friendly_Forms_in_PHP/20/60144/inde...
:

echo '<tr><td>First name:</td><td><input type="text" name="first_name"
value="'.htmlspecialchars($_POST['first_name']).'"></td></tr>';

What purpose do the single quotes serve in
value="'.htmlspecialchars($_POST['first_name']).'"

I don't mean the single quotes around first_name. I mean the single
quotes before and after the periods.
Never mind. I figured it out.

Jul 28 '07 #2
On Jul 28, 11:33 am, Reporter <TruckSaf...@gmail.comwrote:
I got the following example fromhttp://www.evolt.org/article/User_Friendly_Forms_in_PHP/20/60144/inde...
:

echo '<tr><td>First name:</td><td><input type="text" name="first_name"
value="'.htmlspecialchars($_POST['first_name']).'"></td></tr>';

What purpose do the single quotes serve in
value="'.htmlspecialchars($_POST['first_name']).'"

I don't mean the single quotes around first_name. I mean the single
quotes before and after the periods.
I am by no means a PHP expert, but I believe you are being misled by
an assumption. The assumption that something is wrong about the single
quotes. That's not the case.
What you have here is a single quoted string that is concatinated to
the result of the htmlspecialchars function, which in turn is
concatinated to another single quted string.
To make thsi clearer remember that the period (.) is the
concatination operator is PHP.

The quotes that are embeded in the strings are the double quotes
(")and the reason for them is that they are required by the html
that is being echoed out.

Finally, the single quotes around the 'first_name' are not embeded
in any string, they are there to make the string 'first_name' the key
(or index) to get thea appropriate value out of the $_POST[] array.
HTH,
- Tom Z
Jul 28 '07 #3

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

Similar topics

9
by: Dynamo | last post by:
Hi, I am still confused as when to use single or double quotes. This works: echo "<td>" . $row . "</td>"; and this does not
9
by: franzkowiak | last post by:
Hello, I've read some bytes from a file and just now I can't interpret 4 bytes in this dates like a real value. An extract from my program def l32(c): return ord(c) + (ord(c)<<8) +...
2
by: girish | last post by:
In my XML document, some node attributes data contains both single quot and double quote characters, such as <input msg="Hello "World", What's up"/>. The double quotes are in form of escape...
5
by: Joel | last post by:
Hi, I incorporated a function in my code that whenever I use a string variable in an sql statement if the string contains a single quote it will encase it in double quotes else single quotes. ...
7
by: gar | last post by:
Hi, I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code text= Replace(text, """", "'" This works fine (for normal double quotes).The problem...
4
by: Justin Fancy | last post by:
Hi everyone, I need to replace all instances of a double quote(") with two single quotes('') in a text file. I already have some replacements of strings going on, but I tried this one, but the...
2
by: L. Berger | last post by:
Hi, I am working on an HTML template which has a lot of html tags, with PHP data shown in the middle of these tags -- you know, the usual. Currently, I have HTML as is, and many many "echo...
15
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about...
4
by: joecolson | last post by:
I've been trying to devise a JavaScript function that will take a GPS latitude or longitude coordinate expressed as degrees, minutes and seconds, and convert it to decimal degrees. Once the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.