Difference Between Single And Double Quote String?

Difference between single quote and double quote string in php. What is the difference between echo 'Test Data'; and echo "Test Data"; in PHP. Both statements give me same output.


Difference Between Single Quote And Double Quote String?

I'm not a major in PHP programming but I'm a little confused why I see some codes in PHP with string placed in single quote and sometimes in double quote. I just know in .NET, or C language, if it is in single quote, that means it is a character, not a string.

View 7 Replies View Related

String - Convert Single Quote To Double Quote In All HTML Tags?

How can I convert all single quotes to double quotes in all HTML tags only? Is there an easier way to do it?

For example: How can I convert this string (actual data from my work):

<TEXTFORMAT LEADING='2'><P ALIGN='LEFT'><FONT FACE='Verdana' style="font-size:10' COLOR='#0B333C'>My name's Mark</FONT></P></TEXTFORMAT>

To this:

<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style="font-size:10" COLOR="#0B333C">My name's Mark</FONT></P></TEXTFORMAT>

View 6 Replies View Related

String Parsing - Double Quotes - Single-quote

I am trying to build a where clause for mysql based on different form inputs but php seems to have a problem with the following:

$whrClause = "WHERE keywords LIKE '%$keywords%'"

I thought with the double quotes that the single-quote and percent signs would remain unchanged and the variable $keywords would be expanded to its value, but I guess I am wrong because i get a parsing error.

View 3 Replies View Related

Single Versus Double Quote Marks As String Delimiters

I have heard other people say that PHP can parse double quoted strings
(e.g., "Hello, World") faster than it can parse single quoted strings (e.g.,
'Hello, World'). This seems backwards to me, since double quote strings
have to be checked for any variables that need to be interpreted, whereas
single quoted strings do not.

So, what is the truth on this matter? And the explanation?

View 12 Replies View Related

Add Single Quote Or Double Quote If Content Have A White Space?

I try to make dynamic CSS using PHP.

Example on font-family

$one = 'Times New Roman, Times, serif';
$two = 'Lucida Sans Unicode, Lucida Grande, sans-serif';
On style.php
body { font-family:<?php echo $two; ?>; }

Here I want to add a single quote or double quote to the Lucida Sans Unicode, Lucida Grande

So the ouput should be

body { font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; }

Let me know how to replace the font with a quote

View 5 Replies View Related

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_F...0144/index.html

echo '<tr><td>First name:</td><td><input type="text" name="first_name"

What purpose do the single quotes serve in

View 2 Replies View Related

Single/double Quote

why are the escaped " (double quotes) printed with the variable? PHP Code:

View 9 Replies View Related

Best To Use Single Or Double Quote For Forming Strings?

Here's something I've been wondering. Do most of you use single or
double quotes as a string encapsultor?

$s = "This is a string, I can embed ' with no prob";
$s = 'This is a string, I can embed " with no prob'

Is there an advantage or best-practice reason to choose one over the other?

View 2 Replies View Related

Find A Single Or Double Quote In $desc That Was Not Escaped.

I am having problems getting php to escape characters, so I can use them with javascript. Here is the code. PHP Code:

$desc = $item['description'];

$desc = str_replace("'", "'", $desc);
$desc = str_replace('"', "'+String.fromCharCode(34)+'", $desc);

echo "<a href='index.php' onMouseover="showTooltip(event,'$desc');return false">Link</a>";

I am trying to get a tooltip to work. It seems to work most of the time, but sometimes the tooltip does not work, and when that happens I can find a single or double quote in $desc that was not escaped.

View 1 Replies View Related

Addslashes Adding Double Backslashes When Escaping A Single Quote?

Addslashes seems to be a bit confused. Given the following 2 lines of code

$name = "Dave's test";
$newName = addslashes($name);

I am expecting $newName to be "Dave's test" (my one single quote nicely escaped)

However, what I'm getting is "Dave\'s test" (note the DOUBLE backslashes). This contradicts every bit of online documentation I can find on addslashes - and causing me a lot of grief.

I am dumping the before and after addslashes results to the http error log via error_log...

error_log("before=$name after=$newName");


before=Dave's test after=Dave\'s test

Note - this is part of an ajax process, so I can't really 'echo' the results.

FYI: I'm Using PHP 5.2.6 under linux with magic quotes OFF.

View 6 Replies View Related

Echo Syntax Error With Single Quote Or Double Quotes?

The is a very simple echo statement but I can't solve it?

echo '"What is your name?'";

View 6 Replies View Related

Difference Between Single And Double Quotes

i understand about the difference between single and double quotes, but are there any benefits of using single quotes other than the speed? and is this speed difference worth while? also, why do double quotes slow the process down?

View 5 Replies View Related

Extract A String From Double Quote?

I have a string

This is a text, "Your Balance left $0.10", End 0

how can i extract the string in between double quote and have only the text 'Your Balance left $0.10' (without the double quotes)

Tried preg_match_all but no luck

View 6 Replies View Related

Use Quote Escapes For Single Quotes Or Use Double Quotes In Arrays?

I realized that I can have problems with single quotes in php arrays:

$lang = array(
'tagline' => 'Let's start your project',
"h1" => "About Me"

So I changed it to double quotes:

$lang = array(
"tagline" => "Let's start your project",
"h1" => "About Me"

Should I use "php quote escapes", instead of what I just did? (by the way how to write "php quote escapes"?)

View 2 Replies View Related

Strpos() Fails To Find Double Quote ('"') In String?

Both this:

echo 'Tok: '.$tok.' Strpos: '.strpos($tok, """).' length: '.strlen($tok).'<br>';
And this:
echo 'Tok: '.$tok.' Strpos: '.strpos($tok, '"').' length: '.strlen($tok).'<br>';

Result in the following output:

Tok: "fresh Strpos: length: 11

Strpos is failing completely to find the double quote, it returns false (I checked with strpos() === false). Can someone tell me what's going on here? I can find no documentation suggesting that strpos can't handle double quotes, why isn't it finding it? I am at my wits end.

View 4 Replies View Related

Removing Single-quote From A String?

I have an HTML form that a user can input text into a title field, I then have php creating an HTML file called title.html My problem is that users can input spaces and apostrophes into the title field that can't be used in the html file name. I replaced the spaces with underscores by using:

$FileName = str_replace(" ", "_", $UserInput);

However, I can't seem to remove single-quotes? I have tried using:

$FileName = preg_replace("/'/", '', $UserInput);

but this took test's and turned it into tests.html.

View 3 Replies View Related

Find String With Single Quote?

I have an array of strings . I need all the strings which do not contain any special character. Only a to z is allowed. Is there any method using regex or is there any string function ?

View 2 Replies View Related

Javascript String With Single Quote Printed From Code?

I have following script printed from PHP . If some one has a single quote in description it shows javascript error missing ; as it thinks string terminated .

print "<script type="text/javascript">
var Obj = new Array();[code]....

Form does a post to this page and title and description comes from textbox.Also I am unable to put double quotes around {$_REQUEST['title']} as it shows syntax error . How can I handle this ?

View 3 Replies View Related

Escaping Single Quote Of String Echoed To Input Text Box?

I need to ouput a last name to a input text box.  The name has a single quote in it.  I can only get the text before the quote to output.  Here is my php code:

echo "<div class='fifteen'>$i. First name:</div><input type='text' value='$firstName' id='$first' name='$first' size='12' />  Last name:$lastName <input type='text' value='$lastName' name='$last' id='$last' size='12' /> Year: ";

The $lastName variable has a single quote in it. I've tried addslashes, stripslashes, and mysql_real_escape_string alone and in combination all to no avail.

View 3 Replies View Related

How To Strip Quotes (single And Double) From A String

I have used a class called clsMetaContent.php, as provided in the book Creating Interactive Websites with PHP and Web Services, by  Eric Rosebrock - who I understand is the lead developer of this site.

While using this class with my application - I find a problem in the assignment of the description for the description part of the meta tag.

The code in the class looks like this:

// Formulate the description for each page.
         $description = $this->description;
      } else {
         $description = '$ptitle - $this->description";

I have found that my description can contain single and/or double quotes. Which causes a problem with the assignment of the meta tag for the description. What happens is, due to the error in the format of the meta tad description, it outputs the contents of description again on the start of my web page, instead of keeping it within the meta tag assignment.

I think I just need a function to strip out double and single quotes - but have been unable to find any.

View 8 Replies View Related

Regex For Matching Double And/or Single Quoted Strings Within In A String?

I'm working on a template class and I've an issue when trying to parse out a list of quoted strings from a string argument list. Take for example the string:

$string = 'VAR_SELECTED, 'Hello m'lady', "null"';

I'm having a problem coming up with a regex that extracts the string "Hello m'lady" and "null". The closest I have got is

$string = 'VAR_SELECTED, 'Hello m'lady', "null", 'TE'ST'';
preg_match_all('/(?:[^']|\\.)+|(?:[^"]|\\.)+/', $string, $matches);


View 3 Replies View Related

Pre_match Check If String Is Surrounded In Double Or Single Quotes.

the regex to see if something is surrounded in double or single quotes.

"this is the string"

i want it to return false if it quotes are not present at all or not present at the start and the end.

View 2 Replies View Related

Convert Double Quoted String To Single Quoted Literal String

Is there a way to convert the double quoted string "<b>foo</b>" to the single quoted string '<b>foo</b>'. note that I cannot use <?php strip_tags("<b>foo</b>")?>, I need to tags to be present. EDIT: I should have asked a question, I would like to styling to be removed, I don't wish foo to be boldened - just for <b>foo</b> to be echo'd to the screen.

View 1 Replies View Related

Single Quoted String Not Equal To Identical Double Quoted String?

I haven't used PHP since 2007, so I am a bit rusty, but I have come across a strange bug. I am running php 5.2 Non Thread Safe on Windows IIS on vista. Problem is when using single quotes.

if ('hello' == "hello") This returns false
echo stren('hello'); This returns 7
BUT if I do this:- echo strlen("hello"); (which returns 5)
THEN do echo stlen('hello'); (with the single quotes again, returns 5);
AND if ('hello' == "hello") Now returns true;

View 14 Replies View Related

Escape Single Quote Within Single Quotes Query

I'm trying to write a web scraper for the source code of a webpage. The regex expersssion I'm using is (.+?) which means match everything from here until the delimiter which is a ' character.

$regex = '/&kingdom=(.+?) ' /';preg_match($regex,$data,$match);var_dump($match);echo $match[1];()

The problem is that I can' delimit at the ' character.I've tried escaping it like ' but that doesn't work. How do I use the ' character correctly inside single quotes?

View 7 Replies View Related

Double Quote

For example, PHP Code:

$res = mysql_query("SELECT * FROM members");
$row = mysql_fetch_array($res);

$username = $row[username];
$username = $row['username'];
$username = $row["username"];

View 1 Replies View Related

Echo Double Quote Problem

google and manual do not say much for printing double quotes in a path case.

To facilitate your reading (I don't know how to make it colorful in
newsgroup), i'd appreciate studying the code at:


removing tr, td and using combinations of single and double quotes did not
solve the problem :(

View 3 Replies View Related

Preg_replace Double Quote "

I'm import .csv files that are delimited in one of the following ways.


I can get them both to explode, but I can't get the double quote " removed. Thought that preg_replace might do the trick, but I can't figure out how to get it to find the double quote and replace it with nothing. If there is a better way of fixing the problem or importing the file I'm happy to listen. Re-saving the file is not an option in this case.

View 5 Replies View Related

Write The Value That Has Double Quote And Comma Together To Csv ?

I need to get columns value from db and write them to CSV.Some of value of column called question has comma, so I did something like this

PHP Code:

to put that value in one column in CSVbut I found some value contains double quote("") and comma together, something likePHP Code: I have "big" quesiton, that I want to know.So if I put the above code logic, it still separate into 2 columns in CSV. First column has

View 4 Replies View Related

Variables - Convert Single Quoted String To Double Quoted

I have a string returned from a database query which contains variables, however it appears that these strings are all returned single-quoted and therefore the variables are not evaluated as they would be if it was double quoted. what is returned from the sql query would be the $result: This will not evaluate the 2 variables:

$myname = 'david';
$occupation = 'Beginner';
$result = 'Hello my name is $myname and I my occupation is $occupation';
echo $result;

This will evaluate the 2 variables:


My question is how do I convert a single-quoted string to a double-quoted string which is able to evaluate the variables?

View 2 Replies View Related

Copyrights 2005-15 www.BigResource.com, All rights reserved