|
|
|
|
![]() ![]() |
Nov 17 2007, 08:19 AM
Post
#1
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 525 Joined: 13-October 06 From: Alberta, Canada Member No.: 31,584 |
There are basically two main ways to code your php.
Method 1) Creating a php document with an html look. The you throw in include tags all over the place. Its unorganized, and you have lots of stray files hidden in folders and scattered in your base directory. Its difficult to organize, and you make mistakes easily. Example: CODE This document would be called index.php <html> <title>Whatever</title> <body> <table width=750> <td>Banner or something</td> <tr><td width=500>Some content here. Mostly along the lines of <?php include "whatever content page"; ?></td><td width=250><?php include "whatever navigation page"; ?></td></tr> </body> </html> You might ask what the problem was? Well, those include tags tend to multiply, and so do all those unnecesary content pages all over your sever. It gets quite messy and you can make some bad errors when that happens. Method 2) In order to avoid this we can make up for many of those extra pages by including much of the content in the same php tag! CODE <?php //---------------------- //content is going here //--------------------------- $content[1] = <<< html WHATEVER CONTENT GOES HERE html; $content[2] = <<< html MORE CONTENT GOES HERE html; $banner = <<< html <img src="whateverpath"> html; $footer = <<< html <img src="whatever path"><br> copyright blablabla html; //-------------------------- //layout is below //------------------------- $layout = <<< html <table width=750> <td width=750>$banner</td> <tr><td width=500>$content[1]</td><td width=250>$content[2]</td></tr> <tr><td width=750>$footer</td></tr> html; echo "$layout"; ?> Understand? Its very neat, very manageable, and very versatile. Another great advantage to this is that if you have a bunch of buttons for affiliates/whatever, you can easily include them wherever just by placing the button variables wherever you want them. As you get better at php and this technique, you may eventually be able to have all you pages on one file... it may be a little adventure when you code but its possible if you put all of you different pages as variables and just link to those variables... Well I hope you enjoyed this and I hoped it helped. |
|
|
|
Nov 17 2007, 03:11 PM
Post
#2
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 13 Joined: 17-November 07 From: USA - PA Member No.: 53,194 |
Wow! This is really cool. I am so using this on my website
|
|
|
|
Nov 17 2007, 05:33 PM
Post
#3
|
|
|
Newbie ![]() Group: Members Posts: 2 Joined: 17-November 07 Member No.: 53,225 |
here is a few php editors you my be interested in:
PHP Rite 1.47 QUOTE PHP Rite is a professional php editor that provides advanced features like word select, code block indentation, syntax highlighting, line numbers, and go to line number. In addition, this php website editor has built-in php syntax reorganization functions. You will be able to edit php files and other ASCII files, such as Rich Text files, HTML files, and TXT files. PHP Rite is a small but robust website editor. It has a convenient toolbar with the most commonly used commands. With sequential line numbers, you'll be able to easily identify where you need to add or modify code. You'll also have the ability to indent a selected block of code and have the ability to create a new instance with a single mouse click. Not only does it have all the standard features of any php website editor, the colorize function and automatic syntax highlighting is what makes this software a must have for any webmaster who writes code! # Easy to access toolbar and menu # Open and Save php, HTML, Rich Text, TXT files # Ability to create new instance with a mouse click # Print php, HTML, Rich Text, or TXT files # List of recently used files # Unlimited UNDO and Redo. # Cut, copy, paste functions # Ability to indent a selected block of code # Insert Date/Time in 4 different formats # Select a word feature # Ability to go to any line number # Find and replace functions # Colorize function # Automatic syntax highlighting # Change font size # Custom TAB size # Word wrap 15 day free trial version www.phprite.com DzSoft PHP Editor ver.4.1.0.9 DzSoft PHP Editor is a handy and powerful tool for writing and testing PHP and HTML pages. With its deceptive simplicity, the interface of DzSoft PHP Editor is comfortable both for beginners and experienced programmers, making PHP development easy and productive. Key Features: * PHP and HTML/XML Syntax Highlighting * Built-in FTP Client * The Code Explorer * The File Explorer * Project Manager * NEW: File Search Utility * One-click run and preview * Syntax Checking * Full reporting of errors and warnings * Full control of the input data and environment variables * Support for virtually all currently used Content-Types. That means that you can run scripts which generate any content (for example, images) * PHP extensions supported * Quick insertion of PHP functions * Features for quick navigation in the code * Customizable Code Templates * Possibility to export the source code to HTML and print it with syntax highlighting * Bookmarks * Tabbed multi-document interface * PHP Help support with quick keyword search * Different keymapping schemes (Default, Classic, Brief, Epsilon, Visual Studio) * Windows/Unix/Mac file formats support www.dzsoft.com (other code editors as well) i am sure there are freeware programs as well, just google free php editor |
|
|
|
Nov 17 2007, 10:05 PM
Post
#4
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 525 Joined: 13-October 06 From: Alberta, Canada Member No.: 31,584 |
In my first post I said that you could have all your pages on one file. Well, I'll show you how to do it now, so you don't have to figure it out.
CODE This file would be called index.php <?php $pageone = <<< html blabla bla this is page one!!! html; $pagetwo= <<< html blabla bla this is page two!!! html; $default = "$pageone"; if ($_GET['id'] == "") { $id = $default; } elseif (isset($_GET['id'])) { $id = $_GET['id']; } $template = <<< html <html> <title>Whatevs</html <body> <table width=780> <td width=780> $id<br><br> <a href="index.php?id=$pageone">Go to page one!</a><br> <a href="index.php?id=$pagetwo">Go to page two!</a> </td> </table> </body> </html> html; echo $template; ?> All your doing is creating variables to act as pages. You change the variable when you click a link, so the new variable will be displayed in place of the old one. I'm currently using this for my blog. Also, I recomend using this only for small scale websites, or minisites, etc. If there is one error it blows up the whole page, so the more code you have the harder it is to fix Understand? It took me for ever... so don't be surprised if you can't figure it out for a little while... |
|
|
|
Nov 17 2007, 11:15 PM
Post
#5
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 403 Joined: 14-October 07 From: ERROR 404 Member No.: 51,575 |
Php is really great and just the includes alone have cut down the amount of code I have to write myself by about half.
Thank lord for PHP! |
|
|
|
Nov 18 2007, 06:46 PM
Post
#6
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 525 Joined: 13-October 06 From: Alberta, Canada Member No.: 31,584 |
Theres something I'm having trouble with though.. I can't have any links or anything in the variables which really sucks... no php code either, it has to be straight text... formatting tags work... is there anyway to make it so I can have links and stuff in the content variables?
|
|
|
|
Nov 18 2007, 08:11 PM
Post
#7
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 280 Joined: 5-October 07 From: Random Places Member No.: 51,171 ![]() |
You could also always use the $_GET variables. With $_GET you can create a whole website within a single file.
EDIT: Providing Example How you would use the If statements is like this. CODE <?php if ($_GET['page'] == 'put_name_here') { ?> <!-- HTML Code --> <?php } elseif ($_GET['page'] == 'another_page') { ?> <!-- HTML Here --> <?php } else { ?> <!-- Main Page Here --> <?php } ?> This is how you would do links. CODE <a href="page.php?page=page">Name</a> To include do this CODE <?php
include("page.php?page=page"); ?> This post has been edited by coolcat50: Nov 18 2007, 08:18 PM |
|
|
|
Nov 21 2007, 10:14 AM
Post
#8
|
|
|
Newbie ![]() Group: Members Posts: 5 Joined: 21-November 07 Member No.: 53,438 |
So, could I use PHP to script a website skin, or would I have to learn HTML coding?
It's all a bit confusing at the moment, heheh. I tried to learn scripting for IRC once, but that didn't work out too well. So, anyone care to share a link, or something else on... basic php? Or anything like that. Thanks! |
|
|
|
![]() ![]() |