iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register

Go Back   WebForumz.com > Blogs > The Web for Idiots by Idiots.
Register All Albums Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read

The Web 2.1 for Idiots!

!! We can be Digg-ed by clicking here. !!

ATTENTION: Work on the newest open directory/ search engine/ social network hybrid has begun.Any Questions?


This is the only blog where low-calcium is ok!


Welcome to the humble blog for Idiots, its almost like Web 2.1 for Dummies. EXCEPT its more blunt and half as much sodium.

I own various web-sites here and there and I'll be bloging about the extraneous task of making them from not-so-great to fantastic (in 3 easy years.) Enjoy!

Think Open Source!

Posted April 16th, 2008 at 04:38 PM by TheSealPortalTeam
I don't know about you, but when I'm programming I usually whip up the code as fast and painless as possible, but for some reason as I begin to learn php I have that open source mentality. So here are a few suggestions that can make your PHP project run better in performance and keeping the ability to re-code.

Open Source Mentality!
Lets start with the basics PHP code categories, first you have page code, then you have cross-page code. Those are the two categories of basic PHP. You have code that is specific for a page, like a credit card page; and you have universal code that is used in multiple pages like MySQL connections, the number of items in my cart, a formated time stamp, or a navigation.

The best thing with open source code (or good open source code) is the ability to fide the main page to make global alterations, and the ability to find small things like credit card processing and make changes to that.

The best way to single out the 2 code types.
To many people who have one site PHP truly only has one style or template. All the other pages have to mimic it or act just like the template so your users don't get confused.
The best way to do that is to have a Global Page, I call it the Omni-Page when really its the index.php page.

You can generate an omni-page in 2 ways. You can split the header, main content, and footer into three different php pages like:
Code:
<html>
<head>
<?php
include "core/header.php";
?>
</head>
<body>
<?php
include "core/content.php";
?>
<?php
 
include "core/footer.php";
 
?>
</body>
</html>
The real easiest way is to create one index which looks at many content pages but keeps the footer and header the same and running functions from the main page. I have used this method to make EGTWorlds.com. It looks something like this:
Code:
<html>
<head>
<?php
include "core/includes.php";
?>
</head>
<body><div class="Center"> 
  <div class="header">
       <div class="tagLine"><img src="Images/egtWorlds_logo.PNG"  name="egtWorlds_logo" width="212" height="36" border="0" align="absmiddle" id="egtWorlds_logo" alt="EGT Worlds - <?php 
    
echo $strTagLine
    
?>" /></div> 
<div id="nav-menu">
            <ul>
                <li><a href="index.php">Home</a></li>
                <li><a href="index.php?page=search">Search</a></li>
              <li><a href="index.php?page=login">Log-In</a></li>
                <li><a href="index.php?page=addsite">Add A Site</a></li>
            </ul>
      </div>
  </div>
    <br />
  <div class="MainBody">
  <?php
   
echo    writeHomePageContent($_REQUEST["page"]);
  
?>
  </div>
  <br />
  <div class="SecondBody">
    <h3><?php 
    
echo $strHomeParagraphTitle
    
?></h3>
    <p><?php 
    
echo $strHomeParagraph
    
?></p>    
  </div>
</div>
</body>
</html>
This is the most common form for open source projects and for most web designers. You may also notice this is what the famous Open Source CMS, Joomla, does.

Forming Parts instead of hole's!
The easiest thing for a PHP developer to do is code and code with out any regard for the possibility of having another PHP developer look at it a year later.
This makes and breaks jobs for most people. (Especially if you come back a year later and forget how it works, lol.

The best thing to do is to seperate your functions and code by different PHP files. (Common Sense) Including a global variable file (like the Joomla config or a language file), a global include file (depending on how many secondary PHP files you have you may need this), and a "core" / "bin" folder which will store all the finished code that the web will use.

Seperating the functions:

The best way to seperate functions are in the frequency and the code length of the function. For instance I have a MySQL PHP file that only has 3 functions to allow adding, reading, and removing data from MySQL and it totals under 100 lines of code. Where I may need to seperate a File Uploading PHP function into its own file because it includes advanced bit checks and packet downloads and total 500 lines of code.

If you remember this rule when Open Sourcing your code, you'll get better results:
"If you use multiple times on one page in multiple pages, or if it is bigger than 400 lines of (real code, '{' '}' don't count) code put it into a new PHP File"

A good thing about separating these functions is you can create your self a well coded library and have versatile code to speed up future development of new projects.

Separate text into its own Language file.
Evey good Open Source project has including Dolphin, Jommla, Ellgg, and many e-commerce sites.

This is a great feature and it allows the open source end-user to have the ability to change all the text he or she needs to change to personalize the project to his/her needs, without having to learn PHP or dive deep into code.

Even if you don't have an open source project. This will save you when you boss walks in and spots a misspell and threatens your job because it takes a good day to fix it.

Lastly Generalize Everything
Weather its for uploading a rtf document or accessing the "baby_food" database you want to have versatile and generalized code, or it looses its effectiveness and opens up the door to unwanted spaghetti code. (Hold the tomatoes.)

Really if you head this advice it could save you time & money. It could also spare your end-users frustrations in your open source project, or spare you humiliation and embarrassment in your own projects.

These are key-points for any developer, please don't lose them!

Posted in PHP
Comments 8 Email Blog Entry
Total Comments 8

Comments

Old
I would take that in if I knew how to write PHP.
permalink
Posted May 14th, 2008 at 07:25 AM by A800 A800 is offline
Old
TheSealPortalTeam's Avatar
Mabe you should learn it, its a very easy language.
permalink
Posted May 14th, 2008 at 10:09 AM by TheSealPortalTeam TheSealPortalTeam is offline
Old
PHP sounded like a complicated code. Probably will be easy.
permalink
Posted May 14th, 2008 at 11:03 AM by A800 A800 is offline
Updated May 14th, 2008 at 11:07 AM by A800 (Re-wrote comment)
Old
TheSealPortalTeam's Avatar

Good Luck

Hey there ya go, you'll find its simple. Unless you don't know where ya going. I'd suggest w3schools.com, its free and has always helped me.
permalink
Posted May 15th, 2008 at 09:39 AM by TheSealPortalTeam TheSealPortalTeam is offline
Old
I used w3schools to help me learn some CSS. and Thanks
permalink
Posted May 16th, 2008 at 09:26 AM by A800 A800 is offline
Old
TheSealPortalTeam's Avatar

Thats a good thing

Thats a good thing, that w3schools exists for us cheap developers who are so good we get free training lol. Well self-training anyway, lol.
permalink
Posted May 16th, 2008 at 09:36 AM by TheSealPortalTeam TheSealPortalTeam is offline
Old
lol yeah. Self-training ourselves to victory!
permalink
Posted May 16th, 2008 at 09:38 AM by A800 A800 is offline
Old
TheSealPortalTeam's Avatar
Which really isn't a bad idea.
permalink
Posted June 16th, 2008 at 11:00 AM by TheSealPortalTeam TheSealPortalTeam is offline
 
Total Trackbacks 0

Trackbacks

Recent Blog Entries by TheSealPortalTeam

Search Engine Optimization by vBSEO 3.2.0 RC8