• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved [PHP] Creating simple classes.

Kavvson

Gdy boli cie glowa wez
Joined
Jun 25, 2008
Messages
1,177
Reaction score
72
Location
Poland
I have wrote a simple class + function but it dont work :|

PHP:
class ots
{
function health(){
      $data = $result['health'];
      return $data;
}
}
$ots->health();

The $result['health'] is a sql query. The function should returns health. I dont want to use POT's.
 
Last edited:
I have wrote a simple class + function but it dont work :|

PHP:
class ots
{
function health(){
      $data = $result['health'];
      return $data;
}
}
$ots->health();

The $result['health'] is a sql query. The function should returns health. I dont want to use POT's.

What's the error?

Also, before doing $ots->health();, you must do: $ots = new ots; afaik.

PHP:
<?php
	
	class ots
	{
		public function health()
		{
			$data = $result['health'];
			
			return $data
		}
	}
	
	$ots = new ots;
	
	$ots->health();
	
?>
 
Back
Top