function in class question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Guy
Forum Commoner
Posts: 53
Joined: Sun Jan 12, 2003 3:34 am

function in class question

Post by Guy »

how can i call a function of a class from the class when i didnt do new to the class
exapmle:

Code: Select all

class A
{
	f1()
	{
		echo 3;
	}
	
	f2()
	{
		A::f1();    	 //doesn't work
		$this->f1();	//doesn't work
			
	}		
	
}

A::f2();
Thanks
Guy
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you forgot "function":arrow: parse error

Code: Select all

<?php
class A
{
   function f1()
   {
      echo '3';
   }
   
   function f2()
   {
      A::f1();
   }      
}

A::f2();
?>
Post Reply