First Alternative
Hi! It s probably because you are using double quotes to include the class name. You can alternate between single and double quotation marks like this:
if ( is_user_logged_in() ) {
echo Welcome, registered user! ;
} else {
echo "<div class= vc_button style= display: none; ></div>";
}
Every quotation mark has its own meaning in PHP. Double quotes allow you to insert variables in a string while the single ones not:
Double Quotes
$activity = "programming";
$string = "I love $activity";
echo $string; # I love programming
Single Quotes
$activity = cooking ;
$string = I love $activity ;
echo $string2; #I love $activity
Backticks
These are special because PHP will attempt to execute the contents of the backticks as a shell command and return the output (The backtick operator won t work when shell_exec() is disabled).
$host = www.wuxiancheng.cn ;
$output = `ping -n 3 {$host}`;
echo "<pre>$output</pre>"; # Ping result
Second Alternative
You can also use a stops "." to concatenate strings with variables. You can use them between strings and variables like this:
$class = "vc_button";
$style = "display:none";
echo "<div class=" . $class . " style=" . $style . "></div>";