Jump to content


Photo

Php Made Easy


  • Please log in to reply
5 replies to this topic

#1 thedesignstudent

thedesignstudent

    Family Friend

  • Members
  • PipPip
  • 31 posts

Posted 01 March 2008 - 12:57 AM

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.

#2 thedesignstudent

thedesignstudent

    Family Friend

  • Members
  • PipPip
  • 31 posts

Posted 01 March 2008 - 01:11 AM

:(
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, 01 March 2008 - 01:25 AM.


#3 thedesignstudent

thedesignstudent

    Family Friend

  • Members
  • PipPip
  • 31 posts

Posted 01 March 2008 - 03:39 AM

:(
My Other PHP Tutorial is HERE.

#4 jayc

jayc

    Family Friend

  • Members
  • PipPip
  • 65 posts

Posted 23 November 2009 - 12:20 PM

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...m/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






#5 Jeren

Jeren

    Distant Family

  • Members
  • PipPipPip
  • 124 posts

Posted 23 November 2009 - 12:25 PM

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");?>
-Josh
Simmaster - <a href="http://www.swunleashed.net" target="_blank">SWUnleashed</a> | <a href="http://rpg.swunleashed.net" target="_blank">SWUnleashed Boards</a>

"I don't want to go!"

#6 TCH-Bruce

TCH-Bruce

    Volunteer Moderator

  • Members
  • PipPipPipPip
  • 20,141 posts

Posted 23 November 2009 - 12:27 PM

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"); ?>

Bruce Richards
Forum Moderator
TotalChoice Hosting, Inc.
Webhosting by Total Choice Web Hosting - General Support Forum

I am a Forum Moderator. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users