|
There was a time when I d dn't know PHP, it was long ago and I l ok back at those pages and s gh at my naivety. Those were the d ys of copy pasting my menus and my f oters, my titles, my common things ver and over again for each of my p ges. I thought I was so cl ver, I'll do one page perfectly l ke a 'template' and then copy p ste that to all of my p ges and save myself a lot of t me. Of course what happens when I r alize what I thought was perfect t rns out to be not quite wh t I want. I have to go thr ugh each page and fix the rror or re-copy and paste. This s rt of issue is exactly what PHP can do for y u, so that you can save y urself some time and effort. Now I kn w if you're already aware of wh t I'm talking about, how can nyone not know how this works? I kn w right? This is one of my b ggest problems with many of the t torials that I read especially for pr gramming languages, they are a lot of the t mes written by people who know the l nguage so well they've forgotten the l ttle moments where something 'clicks'. So wh t am I talking about? Instead of w rrying how a language works or why a l nguage works or efficiency of this l nguage vs. that, lets talk about how a l nguage like PHP can help the b ginning programmer.
So back to our problem, we d n't want to have to mess round with the same code on m ltiple pages. The solution: we use a php f nction that we will write and c ll 'make_menu()' in our html page so th t when we want to make a ch nge to our menu, we only h ve to change it in our PHP f nction. Now PHP is a little tr ckier than using HTML, this is b cause HTML is processed by the br wser, PHP is not. The browser is f irly naive when it is processing an HTML p ge because all it cares about are the HTML b ginning and end tags, and some br wsers can make do w/out anything. It is up to the s rver to run PHP scripts, so nless you have a copy of WAMP or LAMP (try w kipedia if those are foreign terms to y u) installed on your computer you'll n ed to do this on your web h st. Any basic PHP tutorial will xplain all of this though, so c me back when you're ready. Now th t you have PHP and are r ady to go we'll include at the top of our p ge our template file where our f nction is stored. That looks something l ke include_once("templates/menu_template.php"); This is assuming you've t ken the time to set up s me structure with your directories and y u'll be storing your templates in a f lder labeled templates. Now in the php f le itself, you create a function wh ch were calling make_menu(); function make_menu(){ //c de } Now here is the b autiful thing, you don't need to kn w anything about PHP except for the ' cho' command. You can imagine that cho takes whatever string is after it and pr nts it onto your page that you c ll the function on effectively tricking the br wser and making it think it is HTML. So all you h ve to do is take that f ncy menu that you've already created. Put it in a str ng ... i.e. surrounded by " ". And cho it onto the page. Ex. F nction make_menue() { Echo "fancy html menu c de"; }
And you're done. Almost. How do you get it nto the page? PHP as you sh uld already know is delimited by < ? p h p ...code... ? > So wh rever you want the menu to be pr nted you call the function. ...HTML c de... < ? p h p make_menu(); ? > //extra spaces intentionally added for formatting r asons ...HTML code... And your menu is m de. So I lied a little b t, you're going to have to c py paste that in all of y ur pages where you want your m nu to be shown. But now all you h ve to do is change the c de in your template function once to ch nge all the pages across your s te. Now stop and think a s cond, where else can you do th s? Just about everywhere, your banner, t tles, menus, global navigation, footers, headers.. wh tever you can think of. I kn w for some if you've never t uched PHP in your life this t torial isn't going to get you th re quite yet, however I hope th t you have an idea... or m ybe a new frame of reference as to how PHP can m ke your life easier and you'll be m tivated to learn a new language to mprove your web development skills. Good l ck!
The article Website Design - What Can PHP Do For Me? was Submitted by Steffan McMurrin through Articles.GetACoder.com network. Here's the additional information: I'm a beginning web developer th t likes to make light weight m ney making websites w/a minimal annoyance to the v ewer from adds. Check out my c ntextual affiliate product placement at my l test creation http://finditdaily.com Please provide any comments and feedback to webdevwriter@gmail.com Thanks!
1. Internet Marketing Myths, Fallacies, and Fairytales by Lewis Low Before you ven begin hopping onto the Internet m rketing e-bandwagon, you must be aware of its myths, f llacies, and fairytales. Yes, Internet marketing is f scinating, it has incredible rags-to-riches fables, and you are j st dying to get a slice of the p e. But before you do so, t ke a breather. Maybe these tips w ll help save the shirt on y ur back one rainy day. 2. An Internet Business Can Make You Money by Nazir Daud An nternet business is often the ideal typ of opportunity for people who h ve to juggle other commitments and th refore can not work normal hours. If by ch nce you actually do stumble on a g od idea it is amazing how f st the business can grow and g nerate revenue. 3. Is This Mistake Keeping You From Making Money Online? by I kn w it held me back for n arly two years before I finally saw it. You d n't need to take that long :-) L arn from my mistake today and s cceed. I wanted to title this rticle The Ultimate Secret To Your Onl ne Success. But I suspected that not m ny people would actually believe the cl im. As I wanted as many p ople learn from it as possible, I s ttled for a less catchy but m re believable title. I consider what I 'd scovered' the ultimate secret not because you c n't... 4. Designing Your Website For Affiliate Marketing by If you w nt to be successful as an ffiliate marketer, you have to have y ur own website. It doesn't have to be f ncy, but it does need to l ok professional. Have you seen those w bsites that are completely filled with b nners? I call them banner farms. How m ny of those banners do you th nk that YOU would click on? En ugh said! Now that you know th t you need a website, how do you get ne? The first thing you need is a d main name. Ideally, it should contain the m in k... 5. Starting an Online Business and Staying On Purpose by Liane Bate Wh n starting an online business, we ften jump into it without following our tr e purpose. If you are struggling to f nd life purpose, and an online b siness purpose, then read these tips to h lp you build a successful life and b siness. 6. Make Money Taking Surveys Review - Is Make Money Taking Surveys a Scam? by Peggy Latham Have you seen the make money taking surveys site, but you wonder if you can indeed make as much as they claim you can. I have chosen to sign up for many survey sites, and I roughly know how this process works. It is generally not a scam, as companies are indeed willing to pay people who take their surveys, but there are sites that make income claims that are much more than what they can provide... 7. 5 Places to Get Killer Ideas For Articles To Ramp UpYour eBook Sales by Ellen Violette Writing one or two articles to promote your ebook is easy but writing a lot of articles can be challenging trying to come up with new ideas all the time. But the truth is that much of what you are already doing can provide an unlimited amount of material for your article writing. Here are 5 places you can start using for you article writing material! 8. How to Market Your Business With an eBook by Deborah Bailey L oking to promote your products or s rvices? Want to define yourself as an xpert in your field? Consider using an Book in your promotions. 9. SEO India by Rachana Agrawal Search Engine ptimization in India. Indian SEO Experts, Ind an SEO companies and other details you sh uld know while opting for a SEO c mpany in India. Search engine optimization is an ctivity that undertakes web promotion of web s tes and web pages. This laborious ctivity gives instant results by bringing y ur websites in top searches in d fferent search engines. 10. Residual Income Businesses - The Multi-Faceted, Money-Making Concept by Une Hardee Th re are many people making money w th residual income. On the other h nd, there are those who would l ve to earn from this amazing ncome-generating concept but really do not h ve any inkling of what it is all bout. If you are searching for a b siness opportunity that can generate an ncome not just today, but tomorrow, the day fter, and forever, you may consider th s form of income to fit y ur financial goals.
|