The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Little questions on PHP string syntax.
$var = "<img width="5" src="/blah.png">"; is bad?
$var = '<img width="5" src="/blah.png">'; is good? $var = "<img width=\"5\" src=\"/blah.png\">"; is good? $var = '<img width=\"5\" src=\"/blah.png\">'; is bad? $var = "<img width='5' src='/blah.png'>"; is good? $var = "<img width=\'5\' src=\'/blah.png\'>"; is bad? $var = "start " . $var . " end"; is good? If someone could clarify this that would be great. Yes they are all different. |
#2
|
|||
|
|||
Simple. Inside HTML text (ie. src="..") double quotes are used to identify text.
With PHP you have 2 options to enclose something: - Single quotes: No evaluation of the content takes place - Double quotes: Content is evaluated (ie. variables and such) If you use double quotes inside a text, and you enclose the text with double quotes, then PHP will not know where the text starts and where it ends. It will read the first double quote as start en the 2nd (ie. the one embedded in the text) as closing quote. To avoid this enclose text that has a double-quote inside by single quotes. Alternative would be to escape special characters like the doube-quote with the escape character \. |
#3
|
|||
|
|||
My personal preference is single quotes then escaping for variables:
PHP Code:
|
#4
|
|||
|
|||
dream weaver man dream weaver thats all i can really say
dream weaver basically builds stuff for you a you go to do stuff |
#5
|
|||
|
|||
Alright, I got it, thanks for your help. I'm almost sure that the questions I originally posted are all right (is good, is bad)
PHP only evaluates " " is good to know, thanks. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|