HomeContact Us
Internet Marketing Malaysia
 
 
Web Malaysiainternetmarketing.com

 
 
Home
About Us
Marketing Tools
Contact Us
How-to Tips & Services
Find What eBay Buyers Want?
Get Google Ads Free!
Google Magic Formula

AdWords Profits 2

MyGoogleTool E-Video Course


To post your articles or receive latest information updates, click here to join as a member for FREE!
  

Members Login
Username :
Password :
Forgotten your password?


Useful Links
Current Events Calendar
Tradeshow Fair Network
Best Investment Online
Small Business Ideas
Beauty Tips & Resources
Expo Conference Network
Website Design - What Can PHP Do For Me?
By Steffan McMurrin

There was a time when I didn't know PHP, it was long ago and I look back at those pages and sigh at my naivety. Those were the days of copy pasting my menus and my footers, my titles, my common things over and over again for each of my pages. I thought I was so clever, I'll do one page perfectly like a 'template' and then copy paste that to all of my pages and save myself a lot of time.

Of course what happens when I realize what I thought was perfect turns out to be not quite what I want. I have to go through each page and fix the error or re-copy and paste. This sort of issue is exactly what PHP can do for you, so that you can save yourself some time and effort. Now I know if you're already aware of what I'm talking about, how can anyone not know how this works? I know right?

This is one of my biggest problems with many of the tutorials that I read especially for programming languages, they are a lot of the times written by people who know the language so well they've forgotten the little moments where something 'clicks'. So what am I talking about? Instead of worrying how a language works or why a language works or efficiency of this language vs. that, lets talk about how a language like PHP can help the beginning programmer.

So back to our problem, we don't want to have to mess around with the same code on multiple pages. The solution: we use a php function that we will write and call 'make_menu()' in our html page so that when we want to make a change to our menu, we only have to change it in our PHP function.

Now PHP is a little trickier than using HTML, this is because HTML is processed by the browser, PHP is not. The browser is fairly naive when it is processing an HTML page because all it cares about are the HTML beginning and end tags, and some browsers can make do w/out anything. It is up to the server to run PHP scripts, so unless you have a copy of WAMP or LAMP (try wikipedia if those are foreign terms to you) installed on your computer you'll need to do this on your web host. Any basic PHP tutorial will explain all of this though, so come back when you're ready.

Now that you have PHP and are ready to go we'll include at the top of our page our template file where our function is stored. That looks something like

include_once("templates/menu_template.php");

This is assuming you've taken the time to set up some structure with your directories and you'll be storing your templates in a folder labeled templates. Now in the php file itself, you create a function which were calling make_menu();

function make_menu(){ //code }

Now here is the beautiful thing, you don't need to know anything about PHP except for the 'echo' command. You can imagine that echo takes whatever string is after it and prints it onto your page that you call the function on effectively tricking the browser and making it think it is HTML. So all you have to do is take that fancy menu that you've already created. Put it in a string ... i.e. surrounded by " ". And echo it onto the page.

Ex.

Function make_menue()
{

Echo "fancy html menu code";
}

And you're done. Almost. How do you get it onto the page?

PHP as you should already know is delimited by < ? p h p ...code... ? > So wherever you want the menu to be printed you call the function.

...HTML code...

< ? p h p make_menu(); ? > //extra spaces intentionally added for formatting reasons

...HTML code...

And your menu is made. So I lied a little bit, you're going to have to copy paste that in all of your pages where you want your menu to be shown. But now all you have to do is change the code in your template function once to change all the pages across your site.

Now stop and think a second, where else can you do this? Just about everywhere, your banner, titles, menus, global navigation, footers, headers.. whatever you can think of. I know for some if you've never touched PHP in your life this tutorial isn't going to get you there quite yet, however I hope that you have an idea... or maybe a new frame of reference as to how PHP can make your life easier and you'll be motivated to learn a new language to improve your web development skills. Good luck!


I'm a beginning web developer that likes to make light weight money making websites w/a minimal annoyance to the viewer from adds. Check out my contextual affiliate product placement at my latest creation http://finditdaily.com

Please provide any comments and feedback to webdevwriter@gmail.com Thanks!

© Internet Marketing Malaysia (Online Marketing and Web Marketing Tips and Articles)   powered by eventogo.com