Make everything in the variables value not relevant to the rest of the page? |
Make everything in the variables value not relevant to the rest of the page? |
allenph |
Mar 4 2012, 06:45 PM
Post
#1
|
Novice Group: Members Posts: 21 Joined: 15-February 12 Member No.: 16,477 |
So what i mean is if i set a variable to "[" ($some_variable = "[") the rest of my code is now going to go CRAZY because there is an open [. Is there a way I can just make everything inside the first set of "" not relevant to the code? thanks!
|
Brian Chandler |
Mar 5 2012, 01:11 AM
Post
#2
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
So what i mean is if i set a variable to "[" ($some_variable = "[") the rest of my code is now going to go CRAZY because there is an open [. Is there a way I can just make everything inside the first set of "" not relevant to the code? thanks! I'm not sure what you solved, but the above question seems to be a gross misunderstanding. A variable is like a "box"; it holds a value. In PHP this value can be of various types -- an integer, a floating point number, a string of characters, a boolean (TRUE or FALSE), plus some really confusing stuff like NULL. But whatever value you assign to the variable, that's it: the variable just sits there holding the value. Unless you do something with it -- like copying to another variable, or using as an argument (parameter) to a function, it has no effect on anything else. So if I write $open = '['; $close = ']'; this makes these variables hold these character values. It does not make anything go crazy. But note it's generally a good idea to represent string literals with single-quoting, unless you are using the variable replacement thingy, e.g. with $expression = "$open$var=$value$close"; ... possibly making $expression equal to '[name=brian]'. |
Lo-Fi Version | Time is now: 26th April 2024 - 09:08 AM |