Jump to content

A PHP Contest, Anyone ?


Recommended Posts

PHP, Hypertext PreProcessor (or originally "Personal Homepage") is a server-side scripting language to write dynamic webpages. Our forum engine is written in php, our websites will be, too.

Basically you program your site with arrays, classes, functions, methods, variables and everything a real programming language has to offer (PHP5 will offer some more OOP stuff, so that it will be a full OOP-capable language like JAVA very soon) and send the code to your server.

Then the server generates the html and sends it back to the browser, which displays it.

An example:


<?php

echo "<table><tr><td>Hallo Leute</td></tr></table>";

?>

will put a simple table with "Hallo Leute in it" to the screen.

However, there are complex functions with classes etc.

Here is one from the Task System I made for WFG (and which i am still developing):


<?php

/*
+--------------------------------------------------------------------------
|   Wildfire Games Intranet
|   ========================================
|   by Tim [DarkAngelBGE] Koschuetzki
|   ========================================
|   Email: DarkAngelBGE@aol.com
+---------------------------------------------------------------------------
|
|   > Index module -- Manages the entire Task System
|   > Module written by Tim Koschuetzki
|   > Date started: 11th November 2003
|
|     > Module Version Number: 1.0.5
+--------------------------------------------------------------------------
*/



class cl_task_system
{

var $task_html;


//-------------------------------------------
// CONSTRUCTOR FUNCTION
//
// Decides what to do based on the url vars
// act and code, calls the Email Reminder
// func and puts up the page's title as well
// as the navbar stuff
//-------------------------------------------

function cl_task_system()
{

 global $site, $std_func, $DB, $display, $INFO;

 //-------------------------------------------
 // Parse the header, left nav and right nav
 // to the Skinning System
 //-------------------------------------------

 $std_func->std_navbar( &$l_nav_cats, &$l_nav_items, &$r_nav_array );

 $display->add_output( $site->html->header( $INFO['site_name'].' -- Task System' ) );
 $display->add_output( $site->html->left_nav( $l_nav_cats, $l_nav_items ) );
 $display->add_output( $site->html->right_nav( $r_nav_array ) );


 //-------------------------------------------
 // Load the Skin Stuff
 //-------------------------------------------
 
 $this->task_html = $std_func->load_template( 'task' );
 
 
 //-------------------------------------------
 // Decide what to do
 //-------------------------------------------

 switch ( $site->vars['input']['code'] )
 {
  case 01: $this->new_task();
  break;
  case 02: $this->view_task();
  break;
  case 03: $this->edit_task();
  break;
  default: $this->view_task();
 }

 // Remind people of their tasks
 $this->email_reminder();
 
}

...

} //class

It is the master class for the Task System Module and its contruct function works out, which function to start upon some values of variables.

Got a first insight ? ;)

Link to comment
Share on other sites

I'll have a go, as long as it doesn't take too much time (or Stuart will have my head).

I'm curious, though, why was the task code all wrapped up in a class? Personal style considerations, or is it actually easier that way?

Link to comment
Share on other sites

It is actually easier, because that way I can just have another class if I make a new module (like the memberlist or so) and use functions...well for each function so to speak. ;)

Also, it looks more easier (the code) and more l337. B)

You have PHP experience, mrk ? For how long ?

Link to comment
Share on other sites

Erik: Yes. :brow:

Tim: Well. I've been playing with PHP a while, but haven't really had much need to use it very often, seeing as I don't really have a web presence. About a year, perhaps. Used ASP for a couple of years, too.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...