Jump to content

Pointers in Php


supertrucker

Recommended Posts

you mean as in memory pointers? Kind of. you put a & sign in front of the variable.

function bob(&$memory){  $memory = 'Hi';}$var = array('one','two');var_dump($var);bob($memory);var_dump($var);

Link to comment
Share on other sites

Perfect, thank you! Here's the function I needed it for, to post what could be an unset variable back to a form:function ghostw(&$v){ if (isset($v)) { echo $v; }else { $v='';}}

Link to comment
Share on other sites

Yes, PHP does not have C-style pointers, and the references in PHP don't even reference memory, they reference an entry in a symbol table built by PHP. So PHP has references, but not like C, and not pointers.
Well in anycase, thanks for the help, as it did exactly what I needed it to! I don't even know how to use C style pointers, but I am familiar with them from programming a little in Pascal.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...