What is the most pointless use of PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
zorka
Forum Newbie
Posts: 9
Joined: Fri May 24, 2002 8:29 am
Contact:

Post by zorka »

user: i want to make a webpage for my department
admin: ok, here are the templates you have to choose from. you can change the content, but you can not modify the layout or the color scheme.
user: ok. but i want to make this line bigger, and red and flashing.
admin: sorry, that is not available in these templates.
In a true CMS system the admin would simply give the user access to edit the page and review his changes after they were made. If the admin had done his homework the user would already have access to create and edit pages for his department. If the user shouldn't have acess to modify the page then the user should contact his department head.

Some of you know that I work for a company that has built our own PHP application framework which separates logic and html called http://www.logicreate.com (some of you may not). Here is how the LogiCreate system handles this separation of templates and logic.

This is what we call the "welcome module". It's job is for learning purposes and can be changed to fit ones needs

Code: Select all

<? 

class welcome extends FuncMapAuth &#123; 

   var $presentor = "htmlPresentation";  // presentation handler 

   function run(&$db,&$u,&$arg,&$t) &#123; 
	$t&#1111;"time"] = date("h:i:s"); 

	// choose your template 
	$arg->templateName = 'main'; 
	
	// grab something from the Database 
	$db->queryOne("select name from users where username='$u->username'")

	// pass the name to the template 
	 $t&#1111;'name'] = $db->Record; 
   &#125; 
&#125; 
?>
In the system, anything passed to "$t" is passed to the template. Here is an example of the template which is called "main.html":

Code: Select all

<h3>Hi <?=$t&#1111;'name']?></h3>
The current time is: <?=$t&#1111;"time"]?><br><br>

Thank you <?=$t&#1111;'name']?> for visiting our site.  We hope you will come back to see us later.
You'll notice in the above "template" it is simple text and HTML. Anybody that knows HTML can edit this and be simply told which "PHP TAGS" to drop in the template when they are doing the design layout. This separation allows a developer and a designer to work at the same time without intervention. If you want to know more about how this system works and is used, AIM or YIM me offline, there is no need to clutter up the forum with commercial rhetoric as I just wanted to show an example of how templates can be used in a framework or CMS instead of what is currently out there.

--ZorKa
User avatar
gotDNS
Forum Contributor
Posts: 217
Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA

Post by gotDNS »

- Remember kids, much of HTML is supported by most browsers, and since PHP is parsed on your server, do everything you can in PHP :D

- Note to people that speak of 'hackers' as 'cracking' things.
"Hackers build things, crackers break them." - Eric S. Raymond
User avatar
NetDragonX
Forum Newbie
Posts: 15
Joined: Sat May 25, 2002 3:00 pm
Location: Southern California

Post by NetDragonX »

lol - all this talk about PHP vs. JavaScript... well a suggestion for you:

Use both JavaScript and PHP in your form validation.

That way, if a user has JavaScript disabled... you can always have server-side PHP cover validation. Also note that if they do have JavaScript enabled, the PHP validation shouldn't bother the process at all. So it's a win-win situation.

:)[/i]
User avatar
sam
Forum Contributor
Posts: 217
Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:

Post by sam »

There is no such thing as pointless php. If it is the quickest and simplist way to get the job done, use it. Enough said.

Cheers Sam
User avatar
phphead
Forum Newbie
Posts: 12
Joined: Tue May 28, 2002 11:03 pm
Location: California

Templates are the base of php.

Post by phphead »

most pointless? PHP template engines....*sigh*
:roll:
now, php started as a perl based template parser. Before the zend rebuild that is all it was. dont go ridiculing template parsers because of their pointless stupidity.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Template engines are good.

Building template engines out of PHP that essentially create a scripting language of their own (like Smarty) are overkill.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

most useless use:

kids who get a server with php, but only use 1 or 2 premade php scripts...sure its nice to use other peoples work, but you have to come up with your own stuff sometime..
dkode
Forum Newbie
Posts: 1
Joined: Mon Jun 10, 2002 7:31 am
Location: Planet Namek

Post by dkode »

I have started to use Smarty Template with PEAR DB about 2 weeks ago. So far it has proven to save me alot of time/effort

I beleive with designer like myself that are developing multiple websites at once. These template systems prove to be very useful and effecient.

I can quickly and easily create a CMS for a client versus code one by hand which I used to do and would take 2+ days. Using Smarty Template I have gotten that development time down to 2-3 hours instead.

I think for certain people template systems will be more useful. I am one of those people that it helps me greatly improve my effeciency. The sites I do use it on arent getting globs of hits but thus far I cannot tell a difference at all in load time.

Actually, if I have caching on (in most cases) the execution time is actually very sped up because there is no need to redundantly access the database.

Theres my 2 cents. :D
Post Reply