LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-02-2006, 03:58 AM   #1
ice99
Member
 
Registered: Aug 2005
Posts: 51

Rep: Reputation: 15
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.
 
Old 12-02-2006, 05:00 AM   #2
musicman_ace
Senior Member
 
Registered: May 2001
Location: Indiana
Distribution: Gentoo, Debian, RHEL, Slack
Posts: 1,555

Rep: Reputation: 46
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.

Last edited by musicman_ace; 12-02-2006 at 05:04 AM.
 
Old 12-02-2006, 05:57 AM   #3
ice99
Member
 
Registered: Aug 2005
Posts: 51

Original Poster
Rep: Reputation: 15
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.
 
Old 12-03-2006, 09:12 PM   #4
vargadanis
Member
 
Registered: Sep 2006
Posts: 248

Rep: Reputation: 30
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...
 
Old 12-03-2006, 10:14 PM   #5
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
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.

Last edited by vharishankar; 12-03-2006 at 10:19 PM.
 
Old 12-04-2006, 06:43 AM   #6
vargadanis
Member
 
Registered: Sep 2006
Posts: 248

Rep: Reputation: 30
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding users with PHP (pass php variables to Expect script) Jayla Programming 1 10-20-2006 10:44 AM
LXer: Title: PHP/MySQL Classifieds Script AddAsset1.php Script Insertion LXer Syndicated Linux News 0 07-02-2006 06:21 PM
PHP -- How to execute a shell script from PHP using FTP functions?? zoonalex Programming 3 07-29-2004 11:51 AM
Red Hat 9 server can't write PHP script, problem in httpd.conf file? x_menno_x Linux - Newbie 27 06-29-2004 04:44 PM
php script can not write text file lemotion Linux - Newbie 5 04-20-2004 10:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration