Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > No built-in function inside a class?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 31st July 15:30
connectcase
External User
 
Posts: 1
Default No built-in function inside a class?



If I define a class in PHP, I don't seem to able to use built-in
functions, like:

Class User
{
var $username = strlen("something");
}

The strlen gives a parse error. What will work is:

define("USERSOMETHING",strlen("something"));
Class User
{
var $username = USERSOMETHING;
}

but this is like defining your variables twice, so I want to avoid
this. Any ideas?

Thanks

Cees
info@connectcase.nl
  Reply With Quote


  sponsored links


2 31st July 15:32
External User
 
Posts: 1
Default No built-in function inside a class?



Do it in the constructor:

Class User
{
var $username;

function User(){
$this->username = strlen("something");
}
}
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666