Jump to content

Just Curious


jblack

Recommended Posts

Not quite sure what you are talking about but :

$fetch=mysql_fetch_object(mysql_query("SELECT * FROM table WHERE something='something'"));if($fetch->something!=something){echo"Something";}

Not quite sure it was the fetch-> you where after but well here it is :)->Kristian_C.

Link to comment
Share on other sites

The -> is to access a method in a class.

<?php	class Example	{		public function Hi ( $param )		{			return $param;		}	}	?>

Then:

$example = new Example;echo $example -> Hi ( 'Hee!' );

Link to comment
Share on other sites

In the general sense, it is the operator to access any class member, not just a method. A class is a complex data structure that contains variables, referred to as class properties, and functions, referred to as class methods. A class for a door might look like this:

class Door{  var $opened = false;  var $locked = false;  function open()  {	$this->opened = true;  }  function close()  {	$this->opened = false;  }  function lock()  {	$this->locked = true;  }  function unlock()  {	$this->locked = false;  }}

This is just a simple example to illustrate a class (you probably wouldn't have a "Door" class in many applications). You can see that the door class has 2 properties, to indicate if it is opened and locked. There are 4 methods that you can use to open the door, close the door, lock and unlock it. If you are using this class in your application, you would create a new "instance" of this class like this:

$red_door = new Door;

This creates an object of the Door class and keeps it in the $red_door variable. If you want to close and lock this door, you would use the close and lock methods, and you would access them like this:

$red_door->close();$red_door->lock();if ($red_door->locked == true)  echo "the door is locked";

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...