Jump to content

Constructor question


TomTees

Recommended Posts

That is a java/C++/C# instruction, though I haven't yet seen it in use within the context of a php class. Typically the __construct() method is just defined on it's own (except when a class is extended I believe (though I am most likely wrong there - don't use that too much myself))

 

__construct(args...)

 

That is used to pass things into the class at runtime - that's how I have always understood it to be anyway, then within that method, you would use it to setup controller or error array's, at least that's normally how I do it ;-p

 

Rw

Link to comment
Share on other sites

When you define functions you don't need to specify the return type; in fact, you can't, but for functions that come bundled with PHP the manual tells you the return types. PHP isn't a strict-typed language, but types do still exist. Just because you can't define explicity what a function must return, it doesn't mean that it doesn't return a variable of some type.

 

For example, consider the following function:

 

function some_function() {
    return "This is a string!";
}

 

There is obviously no explicit definition for the return type of that function, and such a declaration isn't possible in PHP, but that function will always return a string type.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.