The advertisement variables using curly braces [php]?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
29 views
Came across a blog entry of one team about how they fiercely reduce the amount of code.

All anything, but the look caught on design

if(!${0}) log('Writing failed');



The question is - what language is the ability to advertise the variables in braces, and why I can using this method give them digital names?
by | 29 views

3 Answers

0 like 0 dislike
Using curly braces allows you to apply the address to the identifier variable name.
\r
A simple example:
\r
$name = 'value'; $value = 'test'; echo ${$name}; // prints test 

\r
You can also access properties of an object:
\r
$name = 'propertyName'; echo $object->{$name}; 
by
0 like 0 dislike
> if(!${0}) log('Writing failed');
Idiots code wrote
Gone are the days when saving bytes.
\r
now there is a byte celery (accelerators) that cacheroot opcode, this is the savings are not effective.
\r
code should be clear first of all the programmer, and then the car.
by
0 like 0 dislike
$name = 'propertyName';
echo $object->{$name};
\r
If not mistaken, in this case, the {} can be omitted.
I think that's the best fit this situation:
echo $object->{$name+"_index"};
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
asked May 4, 2019 by vanillathunder
0 like 0 dislike
1 answer
asked Jun 14, 2019 by Slavich_Khe
110,608 questions
257,186 answers
0 comments
27,911 users