egbaseball29
08-15-2003, 11:27 PM
Hi this is my site No advertising, please ok and I want to have it so I can change things and when I do all the pages change which is php if im not mistaken.. But i need a free host that has it thats the first thing and the 2nd is how to use PHP....
Please help me in any way thank you!
Darealmman
08-16-2003, 01:04 PM
PHP is very different to HTML, and I don't know where your website is, the link was removed.
I'll write some things about php for you..
PHP: First Script
<?php
print ("Hello World!");
?>
The Script above will make the browser write or print ' Hello World'. We use the <?php tag to start some php, and to let the browser know we're starting php. We use the print () function to print the string we made Hello World! Lastly, the ?> to end the script.
PHP: Variables
In PHP, many things are stored in variables, variables can hold values for various things.
<?php
$VariableName = SomeValue;
?>
We use the '$' symbol followed by a Variable name to make a variable. We then type '=' and then a value for the variable. Last we end the variable by typing ';'.
Lets use what we learned above to write a script.
<?php
$MyVariable = Hello!;
print ("$MyVariable");
?>
In this script, we made a Variable called '$MyVariable', and assigned it the value of 'Hello!'. We then told the browser to print () or write our Variable.
PHP: Arrays
Arrays are like Variables that can hold more the one Variable.
To make an array we..
<?php
$ArrayName = array ("Value", "Value2", "Etc");
?>
We now have an array with the values, Value, Value2, and ETC.
Say we want to print those, we use the print () function
<?php
$ArrayName = array ("Value", "Value2", "Etc");
print ("$ArrayName");
?>
This script will then print all the values in our arrays. Now, say we want to print one Value.We..
<?php
$ArrayName = array ("Value", "Value2", "Etc");
print ("$MyArray = [2]");
?>
This will print the second value in the array.
You should read a book or website for more info on PHP.
PHP: Functions
Functions are used everywhere. We used the print () function in our very first script! You can use pre-made functions such as printBR (). Or you can define a function and make it yourself like so..
function MyFunctionName ( Argment1, Arugment2, Etc ) {
//Code to be done
}
So, lets dive right in and make a script to add two numbers.
<?php
$Number1 = 506;
$Number2 = 200;
function AddNums ( $Number1, $Number2 ) {
$Number3 = $Number1 + $Number2
return $Number3
}
?>
Notice how we didn't use the print () function, we used return. This is because we made the new variable $Number3 within that function. Therefore, the Variable is only available within the function, so we need to make it print by using return. We include the variables $Number1 and $Number2 inside teh '()' because those are the variables or arguments being used by the function.
----
That is a sloppy guide I've just thrown together that went way too fast, but should help you learna bit.
I'd recommend you pick up a copy of Sams Teach YourSelf PHP in 24 Hours,
All the best,
Darealmman
P.S. - PM me the link to your site and i can help with whatever you were asking at the top, just sned the question again too.
Dude128
08-16-2003, 08:32 PM
the URL wasn't necessary for the question- there's no use looking at an existing page just to answer how to do that, I didn't think.
it sounds like all you need is PHP includes.
put everything you want included on every page into a separate file, and use this code on each page wherever you want that content to appear:
<?php
include ('yourfilename.ext');
?>