473,725 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_nam e"
value="'.htmlsp ecialchars($_PO ST['first_name']).'"></td></tr>';

What purpose do the single quotes serve in
value="'.htmlsp ecialchars($_PO ST['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 2881
On Jul 28, 9:33 am, Reporter <TruckSaf...@gm ail.comwrote:
I got the following example fromhttp://www.evolt.org/article/User_Friendly_F orms_in_PHP/20/60144/inde...
:

echo '<tr><td>First name:</td><td><input type="text" name="first_nam e"
value="'.htmlsp ecialchars($_PO ST['first_name']).'"></td></tr>';

What purpose do the single quotes serve in
value="'.htmlsp ecialchars($_PO ST['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...@gm ail.comwrote:
I got the following example fromhttp://www.evolt.org/article/User_Friendly_F orms_in_PHP/20/60144/inde...
:

echo '<tr><td>First name:</td><td><input type="text" name="first_nam e"
value="'.htmlsp ecialchars($_PO ST['first_name']).'"></td></tr>';

What purpose do the single quotes serve in
value="'.htmlsp ecialchars($_PO ST['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 htmlspecialchar s 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
2653
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
9772
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) + (ord(c)<<16) + (ord(c)<<24)
2
14468
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 sequence in the XML document. am not able to locate such elements using an XPath expression. I trie the following: //*
5
11453
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. Queston: How do you handle a string that contains both single & double quotes (i.e. 12'X7") Here's the function:
7
20992
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 comes in when you copy a double quote from MS Word and paste it in the text box. What happens is the double quote becomes slanted (“) so my code above can't filter it. I tried to do this text= Replace(text, "““","'")
4
7469
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 syntax is being read wrong. Here is the code: lineFile1 = sr.ReadLine
2
4069
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 $variable" statements mixed in as PHP code. My question: should I leave it like this, with ECHO statements embedded within the tags,
15
4479
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 enased whitespace (to my best memory) AT other times I get an undefined index notice as below: Notice: Undefined index: last_reminder_id in...
4
3243
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 expression is parsed, I've got no problems. My problem lies in converting a string like this: 110"57'9.62532 into its constituent parts, degrees, minutes and seconds. Since the string has an embedded double quote and an embedded single quote, my...
0
8888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6011
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.