The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 18, 2019, 06:58:30 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: function name the same as the class name?  (Read 2821 times)
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« on: April 07, 2008, 10:37:33 AM »

err, i just noticed something with perks webrequest class that made my head hurt...

The class is named webrequest2
the first function within that class is also name webrequest2

um, what?

when does that function ever get called? is it another method of intializing the class, like __construct?
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #1 on: April 07, 2008, 10:39:13 AM »

Correct me if I'm wrong, but doesn't a function with the same name as the class constitute a constructor func, and as such wouldn't it be called every time the class is instantiated?
Logged

hai
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: April 07, 2008, 10:39:22 AM »

That's a PHP4 legacy piece.

in PHP5 is where they introduced __construct() and the other magic functions. In PHP4, the constructor HAD to be named the name of the class, just like JavaScript. That class is due for a PHP5ing, but until then it's still good to go in PHP4.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #3 on: April 07, 2008, 10:40:35 AM »

lol

We posted @ the same time, Perk.
Logged

hai
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: April 07, 2008, 10:51:01 AM »

great minds and all Wink
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #5 on: April 07, 2008, 11:01:24 AM »

ok, its what I figured, just wanted to confirm.

I am trying to strip down the webrequest class to the simplest little "get a URL" function possible.
Basically, file_get_contents, without using that function and keeping it in sockets.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!