Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the & prefix in PHP? [duplicate]

Tags:

php

Possible Duplicate:
Reference - What does this symbol mean in PHP?

The third line of the following code, works well in my local environment but returns an error on my production server.

What does the & prefix mean and why is it returning an error on my production server?

Below is my code;

function add_real_escape_string($value) {
    if (is_array($value)) {
        foreach($value as &$item) {
            $item = add_real_escape_string($item);
        }
    } else {
        if (get_magic_quotes_gpc()) {
            $value = stripslashes($value);
        }
        $value = mysql_real_escape_string($value);
    }
    return $value;
}

The error returned is:

Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in init.php on line 345

like image 773
A-OK Avatar asked Nov 27 '25 09:11

A-OK


1 Answers

It basically is an assign by references.

More about this from the php manual can be found here!

like image 119
Bjoern Avatar answered Nov 30 '25 00:11

Bjoern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!