• 0

PHP Question


Question

4 answers to this question

Recommended Posts

  • 0
This is probably a silly question, but what does -> do in PHP?

586137107[/snapback]

Hi.

In PHP, -> is used to access to member vars and member functions of a class:

<?
// PHP 4
class test
{
   var $foo;
   var $bar;

   function show( )
   {
      echo $this->foo, "\n", $this->bar;
   }
}

$class = new test( );
$class->foo = "Hi";   // $foo in class "test" = "Hi"
$class->bar = "Yo";   // $bar in class "test" = "Yo"
$class->show( );   // function show( ) in class "test" => "Hi\nYo"
?>

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.