Well, PHP doesn't support server side variables like ASP, so you're going to have to do it with a database or something. Every time someone accesses a page, enter the session ID and time into the database. Then to find out how many people are online you just count how many distinct session ID's there are in the last X minutes! That's the general gist, you'll have to develop your own method depending on how your site works.
On mine I log everything, so I can tell where people are, how many people visiting a particular page, and a particular version ('cos different variables generate different pages), how many registered, etc etc etc! Start off small, and then built it up as you go on!