Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP's =& operator

Are both these PHP statements doing the same thing?:

$o =& $thing;  $o = &$thing; 
like image 818
Kev Avatar asked May 08 '11 20:05

Kev


People also ask

What is PHP why it is used?

PHP (Hypertext Preprocessor) is known as a general-purpose scripting language that can be used to develop dynamic and interactive websites. It was among the first server-side languages that could be embedded into HTML, making it easier to add functionality to web pages without needing to call external files for data.

What kind of language is PHP?

PHP (Hypertext Preprocessor) PHP is an open-source scripting language designed for creating dynamic web pages that effectively work with databases. It is also used as a general-purpose programming language.

What is PHP old name?

PHP originally stood for Personal Home Page, but it now stands for the recursive initialism PHP: Hypertext Preprocessor.

What is PHP used for example?

Typically, it is used in the first form to generate web page content dynamically. For example, if you have a blog website, you might write some PHP scripts to retrieve your blog posts from a database and display them. Other uses for PHP scripts include: Processing and saving user input from form data.


2 Answers

Yes, they are both the exact same thing. They just take the reference of the object and reference it within the variable $o. Please note, thing should be variables.

like image 116
judda Avatar answered Sep 21 '22 23:09

judda


They're not the same thing, syntactically speaking. The operator is the atomic =& and this actually matters. For instance you can't use the =& operator in a ternary expression. Neither of the following are valid syntax:

$f = isset($field[0]) ? &$field[0] : &$field; $f =& isset($field[0]) ? $field[0] : $field; 

So instead you would use this:

isset($field[0]) ? $f =& $field[0] : $f =& $field; 
like image 29
Scott Lahteine Avatar answered Sep 20 '22 23:09

Scott Lahteine