quotes

What is faster in PHP, single or double quotes? [duplicate]

心不动则不痛 提交于 2019-11-27 06:18:37
问题 Possible Duplicate: Is there a performance benefit single quote vs double quote in php? Which is faster, single or double quotes and why? Also, what is the advantage of using either method? 回答1: Depends what you want to do. I just did some benchmarks and tested string assignment with a 5 test cases: double quotes + variable, double quotes, double quotes and string append, single quotes, and single quotes with string append. My test code. A million loops. String assignment. <?php $start =

How does bash deal with nested quotes? [duplicate]

别说谁变了你拦得住时间么 提交于 2019-11-27 06:17:37
问题 This question already has answers here : How to escape a double quote inside double quotes? (8 answers) Closed last year . I need to run a command with a syntax like this: runuser -l userNameHere -c '/path/to/command arg1 arg2' Unfortunately, I have to nest additional ' characters into the command itself and I can't tell bash to interpret these correctly. The command I would like to run is actually: runuser -l miner -c 'screen -S Mine -p 0 -X eval 'stuff "pwd"\015'' Unfortunately, bash seems

PHP: different quotes?

空扰寡人 提交于 2019-11-27 05:28:43
What is the difference between the quotes " and ' ? What about `? Is there an error in using different quotes ' and " below? $result = pg_query_params($dbconn, 'INSERT INTO users (username, email, passhash_md5) VALUES ($1, $2, $3)', array($username, $email, $passhash_md5 ) $result = pg_query_params( $dbconn, "SELECT user_id FROM users WHERE email = $1", array( $email ) ) Variable-substitution isn't done when using single quotes ('), meaning that the values in your first example would literally be $1 $2 etc if it was a regular string and not passed on to a function that replaces them. If you

Can JSON numbers be quoted?

╄→гoц情女王★ 提交于 2019-11-27 04:57:23
Can there be quotes around JSON numbers? In most of the search links, it seems that numbers do not "require" quotes. But, should the parsers accept both "attr" : 6 and "attr" : "6" ? If MyParser has a method getInt to get a number given the key, should MyParser.getInt("attr") return 6 in both cases, or throw an exception in the latter case? In JSON , 6 is the number six. "6" is a string containing the digit 6 . So the answer to the question "Can json numbers be quoted?" is basically "no," because if you put them in quotes, they're not numbers anymore. But, should the parsers accept both "attr"

How to escape history expansion exclamation mark ! inside a double quoted string?

痴心易碎 提交于 2019-11-27 04:38:43
EDIT: the command substitution is not necessary for the surprising behavior, although it is the most common use case. The same question applies to just echo "'!b'" b=a # Enable history substitution. # This option is on by default on interactive shells. set -H echo '!b' # Output: '!b' # OK. Escaped by single quotes. echo $(echo '!b') # Output: '!b' # OK. Escaped by single quotes. echo "$(echo '$b')" # Output: '$b' # OK. Escaped by single quotes. echo "$(echo '!b')" # Output: history expands # BAD!! WHY?? In the last example, what is the best way to escape the ! ? Why was it not escaped even if

How do I replace double quotes with single quotes

佐手、 提交于 2019-11-27 04:35:46
How can I replace "" (I think it's called double quotes) with '' (I think its called single quotes) using PHP? str_replace('"', "'", $text); or Re-assign it $text = str_replace('"', "'", $text); Use $str = str_replace('"','\'',$str) Try with preg_replace, <?php $string="hello \" sdfsd \" dgf"; echo $string,"\n"; echo preg_replace("/\"/","'",$string); ?> You can use str_replace, try to use http://php.net/manual/en/function.str-replace.php it contains allot of php documentation. <?php echo str_replace("\"","'","\"\"\"\"\" hello world\n"); ?> Try with strtr, <?php $string="hello \" sdfsd dgf";

Nesting quotes in JavaScript/HTML

做~自己de王妃 提交于 2019-11-27 04:29:21
How do you nest quotes in HTML beyond the second level? As far as I know, there are only 2 types of quotes - single(') and double("). I am aware of escaping using slashes - you have to escape in the code but that escaping won't work at the browser level. What is the accepted method to get around something like the following? <p onclick="exampleFunc('<div id="divId"></div>');">Some Text</p> That code prints to the browser: ');">Some Text You need to use proper escaping/encoding. Either in HTML using character references: <p onclick="exampleFunc('<div id="divId"></div>');">Some Text</p> Or in

Removing double quotes from variables in batch file creates problems with CMD environment

一世执手 提交于 2019-11-27 04:12:49
问题 Can anybody help with effective and safe way of removing quotes from batch variables? I have written a batch file which successfully imports a list of parameters %1, %2, %3 etc. and places them into named variables. Some of these parameters contain multiple words, and therefor are enclosed in double quotes. > "Susie Jo" (%1) > "Smith Barnes" (%2) > "123 E. Main St." (%3) These %variables are next placed in named variables: > set FirstName=%1 > set LastName=%2 > set ShipAddr=%3 verification of

PHP quotes inside quotes

夙愿已清 提交于 2019-11-27 04:01:21
问题 Is it possible to put quotes inside quotes? If so how? Here is my code: <?php echo '<span onclick="$(this).addClass('selected');"> </span>'; ?> 回答1: According to php.net To specify a literal single quote, escape it with a backslash (\). It means you could have: <?php echo '<span onclick="$(this).addClass(\'selected\');"> </span>'; ?> 回答2: You could do this: <?php // some code ?> <span onclick="$(this).addClass('selected');"> </span> <?php // some more code. ?> 回答3: Heredoc is the perfect

PHP static variables in double quotes

*爱你&永不变心* 提交于 2019-11-27 02:07:44
How can I get PHP to evaluate a static variable in double quotes? I want to do something like this: log("self::$CLASS $METHOD entering"); I've tried all sorts of {} combos to get the variable value of self::$CLASS, but nothing has worked. I've currently settled with string concatenation but it is a pain to type: log(self::$CLASS . " $METHOD entering"); Sorry, you can't do that. It only works for simple expressions. See here . micropro.cz Unfortunately there is no way how to do this yet. Example in one of answers here will not work, because {${self::$CLASS}} will not returns content of self::