Jump to content

Recommended Posts

PHP Made Easy

by David Alderson

 

 

This is the one piece of code you need if you are new to PHP.

 

<?php include 'footer.php'; ?>

 

That's it!

 

 

 

1. Insert this in your html.

2. Create a file in Front Page or Dreamweaver and name it footer.php

3. No matter how many pages you have this code on, when you update your footer.php file any page with this code will auto-update when your footer.php is loaded on the server with the changes you've made as long as your web page ends with .php

 

Easy.

 

 

Make one for a header (header.php). Make one for a right side menu and put it in a table (right_menu.php). Make one for a left side menu, etc.

 

 

Throw away all of your .php tutorials, this piece of code is all you need to get started.

Share this post


Link to post
Share on other sites

:(

Last Words

I wish I would have had this tutorial boiled down this easy for me to get started. I did the hello world tutorial which is good and I tried several other lessons.

 

Had anyone told me all I had to do was put that snippet into my html and that would insert the contents of my page wherever that code is, I would have been up and running in 5 minutes.

 

I give credit to this tutorial here, which got me to see the light quickly.

 

 

Applications

So let's say I want to add flash to my menu on my web site on the left side.

 

Well, now instead of making a change and copying and pasting updates of code in each individual web page I instead change my left_menu.php file and load it onto the server, and each of my pages that has the php code in the left table instead of a conglomeration of html and image codes is automatically updated with my php file contents.

 

How cool and easy is that!

 

Do it for a footer, a header, an anything really! That little code along with your contents creates all of your pages. Alter your footer.php, header.php or anything.php file and load it to the server, and anywhere that code appears, changes automatically take place.

 

So cool.

 

 

Conclusions

This is the chase I always wanted to cut to as a business owner when it came to php, so I hope this helps other owners and those who want to have nice things in life by learning more about coding. Be it a personal page that looks nice, or their own mini-empire.

 

 

Thanks

Thanks to everyone here who has taught me, I wanted to take 10 minutes tonight to give something back that might help out someone who's learning. Especially thanking Thomas and Bruce and Tina directly again, and so many others including the head guru who I'm learning from by browsing through the forums about every day

 

I was on the CPanel and Web Host Manager site tonight using the demo versions, and reading about the reseller packages here; who knows what comes next!

:lol2:

Edited by thedesignstudent

Share this post


Link to post
Share on other sites

I installed the PHP handler, and really like the hell out of being able to include other pages using the PHP include function.

 

However I am running into a snag that I could use some help with.

 

I use template files alot, and when I cut and paste a template file into a sub directory, the path to the include file is not updated to reflect that the included file is now in a higher directory.

 

I tried to use a fully qualified name for the include file

 

Top Level <?php include("cssmenu.html"); ?>

 

Sub directory <?php include("http://www.My_Domain.com/cssmenu.html"); ?>

 

But I get a TCH error message

 

Warning: include(http://My_Domain.com/Footer.html) [function.include]: failed to open stream: no suitable wrapper could be found in /home/userName/public_html/Insert2.html on line 23

 

Warning: include() [function.include]: Failed opening 'http://www.kinky-vegas.com/Footer.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/userName/public_html/Insert2.html on line 23

 

I have no clue how to go about writing or installing a wrapper that will permit this, any help will be appreciated

 

I have two work arounds at present, but I would like to be able to simply include files from some of my other web resources in the current site

 

 

 

 

Share this post


Link to post
Share on other sites

Are you saying that you used to have cssmenu.html in a subfolder?

 

If it used to be domain.tld/folder/cssmenu.html and you moved it to domain.tld/cssmenu.html, then you need to show the include relatively.

 

It would be:

<?php include("../cssmenu.html");?>

Share this post


Link to post
Share on other sites

You don't enter a url to the include file you enter it's server path. So if the file is not in same folder you would need to enter the path to it.

 

><?php include("/home/username/path-to-file/cssmenu.html"); ?>

Share this post


Link to post
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

×