Re: functions, the best way to implement and arrange them..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jul 13, 2011, at 3:09 AM, Taco Mathijs Hillenaar-Meerveld wrote:

yes, it was a structure like that i was looking for. so a class is a group
of functions?
i have heard about 'wrappers' to and from what i've heard it is the same
thing?


On Tue, Jul 12, 2011 at 11:36 PM, Karl DeSaulniers <karl@xxxxxxxxxxxxxxx>wrote:


On Jul 12, 2011, at 7:28 AM, Taco Mathijs Hillenaar-Meerveld wrote:

It might be a simple question for the local die-hards among here, but i'm
really wondering about how
developers arrange their scripts and keep their map structures.

today i was looking for the best way to keep my scripts clear and to put
them into maps so i have a clear overview.
the same thing i would do for the scripts, using the functions i have and
throwing them in 1 or more php documents.

i can not find it how it should be done. is it a good idea to put a couple
of functions in just 1 document?
like sessions and login/logout functions?

in my idea i would only need to include a document in the header of my
website and then i'm done, right?

some thoughts, ideas and tips would be appreciated.

kind regards

taco



Hi T,
One way I've found is to set up separate pages.
session.php
database.php
forms.php
etc..

Then in each you create a class named the same

EG for session.php
<?php
class Session
{
       /session vars
       var $username = "";

       function Session(){
             //constructor
       }
       //call your different session functions
       //set username for eg.
}
$session = new Session;
?>

Then call on, say, the username var from a page.

Eg: view_acct.php
<?php include("scripts/session.php")**;
<html>
...
<input name="username" value="<?php echo($session->username); ?>" />
...
</html>

A very loose example, but hope it puts you on a good path..
Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




I would venture to say a class is much more then a wrapper.
but basically setting your back-end pages as classes to control everything with. Makes referencing things in your front end much easier too, since most of the nuts and bolts are in the classes. Yes classes have many functions inside them. whatever you want to use, but there is a somewhat strict structure your classes have to be built in for them to work properly.

I would google something like "php class example" or "php class structure" or "php pages as classes"
That would probably yield some good reads.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux