Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static Functions error?? 1

Status
Not open for further replies.

Programmer76

Programmer
Jul 25, 2006
35
CA
Hi,

I am trying to create a static class but I cannot seem to do so...here is the code:
Code:
class Validate {

	public static function test(){
		echo '<br>TESTING<br>';
	}

}

I get an erro on the declaretion of the function test...

Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}''

I am using PHP Version 4.3.2...

Anyone know what is wrong?

It seems like the static keyword is causing the problem but the way I understand the documentation it is supported...

Any ideas at all??

CES
 
I don't think the static keyword is available in PHP 4.x. The manual only mentions the keyword in its discussion of objects in PHP 5.x



Want the best answers? Ask the best questions! TANSTAAFL!
 
I just read shomething that said the static keyword was introduced in php 5...is that really the case?

Any ideas?
 
Maybe I just got a little confused with this link...


It says:
The static declaration must be after the visibility declaration. For compatibility with PHP 4, if no visibility declaration is used, then the member or method will be treated as if it was declared as public.

Am I just misunderstanding this?
 
Thanks for the link! Answers that question.

Now does anyone know of a workaround for this instead of a file of functions?

I would like to have a class that a can use and not have to instaniate it.
 
Will the construction Validate.test() work?
 
It is definatley a problem trying to create the static function. It does not get far enough to instantiate the object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top