Saturday, 9 December 2017

What does the PHP syntax $var1->$var2 mean?

itemprop="text">

What is the explanation for the
following syntax?



$var1->$var2
// Note the second $

class="post-text" itemprop="text">
class="normal">Answer



You are
calling a property on $var1 that is named the same as the value
of $var2.



For
example:




$var2 =
"name";

// The following are
equivalent
$var1->name;
$var1->$var2;


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...