PHP - can a method return a pointer?

Posted by Kerry on Stack Overflow See other posts from Stack Overflow or by Kerry
Published on 2010-06-02T23:55:54Z Indexed on 2010/06/03 0:14 UTC
Read the original article Hit count: 659

Filed under:
|

I have a method in a class trying to return a pointer:

<?php
public function prepare( $query ) {
    // bla bla bla

    return &$this->statement;
}
?>

But it produces the following error:

Parse error: syntax error, unexpected '&' in /home/realst34/public_html/s98_fw/classes/sql.php on line 246

This code, however, works:

<?php
public function prepare( $query ) {
    // bla bla bla

    $statement = &$this->statement;
    return $statement;
}
?>

Is this just the nature of PHP or am I doing something wrong?

© Stack Overflow or respective owner

Related posts about php

Related posts about pointers