html - PHP - Setting a specific $variable to NULL -
So if I have this code in PHP:
$ class_name;
And I want to put it in my markup like this:
...
In this case how can I declare as variable? Which of the following is the best:
$ class_name; $ Class_name = ""; $ Class_name = NULL; Edit: I am using HTML code in an external HTML file for one of my HTML files (I use the requirement
). Therefore, the first php file should be class = "wrap"
in the div.wrap and other file has its class = "wrap red"
. $ class_name = "";
If you intend to use it regularly in string context, the following things are considered empty:
< Ul> (with an empty string) Test with empty ()
. / Em>
0 (0 as an integer) 0.0 (0 as a float) "0" (0 string False Array () (an empty array) $ var; (a variable declared, but without any value) come For example, in your update, there is no trailing white space after class = "wrap"
, but class = " Wrap red ". If you do not pay attention to the white space on the back, and you are confident that your variable will always be a string, even if it is an empty string, Can go well with implementation, and when the variable skins You will be receiving class = "wrap"
.
I think that it always feels good to be as accurate as possible. Thus, when I'm not aligning the string, I used to put a check to prevent white space on the back.
...
Comments
Post a Comment