Page 1 of 1
Beginner Question
Posted: Tue Mar 06, 2012 1:26 am
by dddmx3
I know this a real beginner question, but here I go:
I have this code:
Code: Select all
<?php phpfmg_checkboxes( 'field_4', "Rush my order (+$30)|I need a design (+$20)|Vectorize my artwork (+$25)" );?>
Problem is, when the php sees "$30" it thinks I'm about to write a new php code but really it's just text. How can I make the $ show up as text?
Re: Beginner Question
Posted: Tue Mar 06, 2012 2:02 am
by twinedev
use single quotes so it does not try to parse variables
Re: Beginner Question
Posted: Tue Mar 06, 2012 2:13 am
by dddmx3
But it added the single quotes..
http://unitedtee.com/order
Re: Beginner Question
Posted: Tue Mar 06, 2012 12:46 pm
by califdon
dddmx3 wrote:But it added the single quotes..r
I don't understand that, but in any case, use the escape character
\ in front of the character you do not want interpreted.
Re: Beginner Question
Posted: Tue Mar 06, 2012 9:08 pm
by dddmx3
You don't understand what?
Why it added the quotes?
Re: Beginner Question
Posted: Tue Mar 06, 2012 9:58 pm
by califdon
dddmx3 wrote:You don't understand what?
Why it added the quotes?
No, I don't understand what you are saying. What is "it" and what quotes are you referring to? Where are you seeing single quotes that "it" changed??
But to return to your original question, you don't seem to understand what double and single quotes are used for in PHP. Either can be used to enclose literal strings, but the difference is that within double quotes, the value (contents) of simple variables (like $xyz) are substituted for the name of the variable ($xyz). So if you want to use the character "
$" as a
literal (that is, to actually print a dollar sign), you must either use it within single quotes, so it won't be interpreted, or use the PHP escape character, the backslash (\), whose function is to "escape" being interpreted. A full explanation of how quoted strings behave can be found at:
http://php.net/manual/en/language.types.string.php
Re: Beginner Question
Posted: Tue Mar 06, 2012 10:09 pm
by dddmx3
Im talking about this.
This code:
I added:
And now it shows the $ symbol
here but it also shows the single quotes.
Re: Beginner Question
Posted: Tue Mar 06, 2012 11:02 pm
by califdon
But you are doing that inside double quotes. If you're going to use single quotes, you have to put them around the outside of the string ('Rush my order (+$30)|I need a design (+$20)|Vectorize my artwork (+$25)'). Once you start a string (with single or double quotes), it will be interpreted as a string until the matching single or double quote is found.
Re: Beginner Question
Posted: Tue Mar 06, 2012 11:25 pm
by dddmx3
Thanks, but that didn't work out too well either.
Code: Select all
<?php phpfmg_checkboxes( 'field_4', '"Rush my order (+$30)|I need a design (+$25)|Vectorize my artwork (+$20)"' );?>
Sorry, I don't know php.
Btw, does anybody know the answer to this?
Re: Beginner Question
Posted: Tue Mar 06, 2012 11:38 pm
by califdon
Get RID of those double quotes! Do it exactly as I showed you.