Page 1 of 1

Underscore naming

Posted: Sun Oct 23, 2005 3:10 am
by stryderjzw
Hi,

I've seen some php functions named, such as:

Code: Select all

$class->_database()
$class->_print()
What does underscore functions do?

My guess was in PHP4, there weren't private functions, so do underscore naming denote private functions?

Thanks![/quote]

Re: Underscore naming

Posted: Sun Oct 23, 2005 6:35 am
by foobar
stryderjzw wrote: My guess was in PHP4, there weren't private functions, so do underscore naming denote private functions?
Sometimes, they are called magic methods in PHP5, but _print() isn't one of them, and they always start with two underscores, like so: __sleep(). Otherwise, it's just a custom function, and in this case probably a replacement for print().

Posted: Sun Oct 23, 2005 9:47 am
by v3rb0
yes, right! usually it says that this is private method. but it still can be accessed from anywhere.