LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How can I write this sing (') in my php script? (https://www.linuxquestions.org/questions/programming-9/how-can-i-write-this-sing-in-my-php-script-506774/)

ice99 12-02-2006 03:58 AM

How can I write this sing (') in my php script?
 
Funny or stupid question, but I'm not PHP programmer, so I hope that someone can help me. I need to insert this sign (') in one of my PHP codes. To be more specific I need for example "rock'n roll" but when I add (') than i get some errors, so i thing that there can be some "code'...

Thanks.

musicman_ace 12-02-2006 05:00 AM

Ok, I keep trying to put this but it always parses the code. If you use the following five characters, it should give you a single quote
& # 3 9 ;

You do not want spaces between them, but if I write those 5 characters together, this html forum renderes it as the ' rather than the text I want it be show up as.

ice99 12-02-2006 05:57 AM

Yes, that works.

Thanks.


Quote:

Originally Posted by musicman_ace
Ok, I keep trying to put this but it always parses the code. If you use the following five characters, it should give you a single quote
& # 3 9 ;

You do not want spaces between them, but if I write those 5 characters together, this html forum renderes it as the ' rather than the text I want it be show up as.


vargadanis 12-03-2006 09:12 PM

I think the print "rock'n roll"; should work but if not you can also use this:
PHP Code:

print 'rock\'n roll'

so
\' = '
\" = "
etc...

vharishankar 12-03-2006 10:14 PM

This
PHP Code:

print "rock 'n roll"

is slightly different from this
PHP Code:

print 'rock \'n roll'

though the result is the same, because when you enter text in double quotes it doesn't mean the same thing as in single quotes. Because if you use variables inside double quoted strings, they are parsed for the value and not for single quoted strings.

vargadanis 12-04-2006 06:43 AM

Hm... good to know. I don't really know the whys just I know what is working what is not. This is the backdrow of self-education. (^_^) With a tacher I probably knew the difference.


All times are GMT -5. The time now is 08:33 PM.