Jump to content

Is it safe to say...


ballhogjoni

Recommended Posts

this does a much better job explaining things than i can:

 

http://us.php.net/zend-engine-2.php

 

 

simple example:

 

class SomeObject {
     function doSomething () {
          echo "hello world!";
     }
}

$thisObject = new SomeObject();
$thisObject->doSomething;

 

output:

 

hello world!

Link to comment
https://forums.phpfreaks.com/topic/123452-is-it-safe-to-say/#findComment-637762
Share on other sites

class myClass {
public $i;

public function __construct() {
  $this->i = 5;
} 

public function i() {
  // method code
  return 2; 
}
}

$x = new myClass();
// will set $y to 5
$y = $x->i;
// will set $y to 2
$y = $x->i();

 

See the differences above. The first is a ref to a class variable.

The second is a class method

Link to comment
https://forums.phpfreaks.com/topic/123452-is-it-safe-to-say/#findComment-637892
Share on other sites

  Quote

  Quote

Actually

$thisObject->doSomething();

 

I think methods have to be called with parentheses even if there are no required parameters... haven't they?

Yes, they do.

 

  Quote

yes. my bad.

 

class SomeObject {
     function doSomething () {
          echo "hello world!";
     }
}

$thisObject = new SomeObject();
$thisObject->doSomething();

 

Link to comment
https://forums.phpfreaks.com/topic/123452-is-it-safe-to-say/#findComment-637896
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.