Underscore naming

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
stryderjzw
Forum Newbie
Posts: 21
Joined: Sat Aug 06, 2005 5:45 pm

Underscore naming

Post 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]
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Re: Underscore naming

Post 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().
v3rb0
Forum Newbie
Posts: 1
Joined: Sun Oct 23, 2005 9:41 am

Post by v3rb0 »

yes, right! usually it says that this is private method. but it still can be accessed from anywhere.
Post Reply