Professional Web Applications Themes

[PHP-DEV] References - PHP Development

The current support for references is mediocre at best. For instance: class foobar { var $variable; function foobar() { $variable = "foobar"; } } //This form of new assignment should be the default $a = & new foobar(); $b = & new foobar(); $b->variable = "Hello"; $array = array(&$a, &$b); //The foreach construct uses copies instead of references. foreach ($array as $element) $element->variable = "Hi"; echo $a->variable; //echoes "foobar" echo $b->variable; //echoes "Hello"; //In order for the above to work, a loop is required. for ($i = 0, $count = count($array); $i < $count; $i++) { $element = &$array[$i]; //shown ...

  1. #1

    Default [PHP-DEV] References

    The current support for references is mediocre at best. For instance:

    class foobar
    {
    var $variable;

    function foobar()
    {
    $variable = "foobar";
    }
    }

    //This form of new assignment should be the default
    $a = & new foobar();
    $b = & new foobar();
    $b->variable = "Hello";

    $array = array(&$a, &$b);

    //The foreach construct uses copies instead of references.
    foreach ($array as $element)
    $element->variable = "Hi";

    echo $a->variable; //echoes "foobar"
    echo $b->variable; //echoes "Hello";

    //In order for the above to work, a loop is required.
    for ($i = 0, $count = count($array); $i < $count; $i++)
    {
    $element = &$array[$i]; //shown explicitly.
    $element->variable = "Hi";
    }

    echo $a->variable; //echoes "Hi"
    echo $b->variable; //echoes "Hi";

    //Variable args are always copies,
    Function foo()
    {
    $args = func_get_args()

    //even loop doesn't work:
    for ($i = 0, $count = count($args); $i < $count; $i++)
    {
    $element = &$args[$i];
    $element->variable = "Hello";
    }
    }

    foo(&$a, &$b);
    echo $a->variable; //echoes "Hi"
    echo $b->variable; //echoes "Hi";

    Thanks for your time,
    [email]LingWittinsightbb.com[/email]

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    LingWitt@insightbb.com Guest

  2. #2

    Default Re: [PHP-DEV] References

    On Sat, 30 Aug 2003 [email]LingWittinsightbb.com[/email] wrote:
    > The current support for references is mediocre at best. For instance:
    >
    > class foobar
    > {
    > var $variable;
    >
    > function foobar()
    > {
    > $variable = "foobar";
    > }
    > }
    >
    > //This form of new assignment should be the default
    > $a = & new foobar();
    > $b = & new foobar();
    > $b->variable = "Hello";
    Try PHP 5, and stop mailing those user questions to the internals
    development list.

    Derick

    --
    "Interpreting what the GPL actually means is a job best left to those
    that read the future by examining animal entrails."
    -------------------------------------------------------------------------
    Derick Rethans [url]http://derickrethans.nl/[/url]
    International PHP Magazine [url]http://php-mag.net/[/url]
    -------------------------------------------------------------------------

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Derick Rethans Guest

  3. #3

    Default Re: [PHP-DEV] References

    Firstly, thanks for the tip.
    Secondly, since you fixed the problems I enumerated in another version,
    it would seem that my posting is relevant to development.

    Thanks,
    [email]LingWittinsightbb.com[/email]

    On Saturday, Aug 30, 2003, at 10:22 America/New_York, Derick Rethans
    wrote:
    > Try PHP 5, and stop mailing those user questions to the internals
    > development list.
    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    LingWitt@insightbb.com Guest

  4. #4

    Default Re: [PHP-DEV] References

    On Sat, 30 Aug 2003 [email]LingWittinsightbb.com[/email] wrote:
    > Firstly, thanks for the tip.
    > Secondly, since you fixed the problems I enumerated in another version,
    > it would seem that my posting is relevant to development.
    That's not your decision to make. It's totally irrelevant.

    Derick

    --
    "Interpreting what the GPL actually means is a job best left to those
    that read the future by examining animal entrails."
    -------------------------------------------------------------------------
    Derick Rethans [url]http://derickrethans.nl/[/url]
    International PHP Magazine [url]http://php-mag.net/[/url]
    -------------------------------------------------------------------------

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Derick Rethans Guest

Similar Threads

  1. Web References
    By sendhil in forum ASP.NET Web Services
    Replies: 5
    Last Post: December 11th, 08:34 PM
  2. Getting references
    By John in forum Ruby
    Replies: 2
    Last Post: November 3rd, 07:35 AM
  3. ASP.net using UNC references and IIS 5.0
    By Erik Lindeblom in forum ASP.NET General
    Replies: 1
    Last Post: August 6th, 09:32 AM
  4. references help
    By slash in forum PERL Miscellaneous
    Replies: 6
    Last Post: July 24th, 11:33 PM
  5. references
    By Carl Furst in forum PHP Development
    Replies: 2
    Last Post: July 22nd, 04:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139