FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP commands need help!





Denvis
So i've just started learning PHP coding and there's a lot i don't know about it. Can anybody clear some things up? What does the following mean?

include
echo
$count
Switch
case

I'm so clueless some of them might be HTML... ehh Sad
rvec
you should take a look at this:
http://www.php.net/docs.php
and start with "Getting Started" because if you don't know what a variable is you really need to start there.
dorinn
i recommend you "Apress.Beginning.PHP.and.MySQL.3rd.Edition.Mar.2008" and php.net ofc Wink
Raidation
include -- To make website design easier. You load a text or php or whatever file and it replaces the include statement with whatever is in that file. Like for a menu. Without include, you would need to manually add a button to each page. With include, you would only need to change the file you include.

echo -- Just to show something on the webpage. For example, echo("Is there an echo in here?"); would be the html equivalent to <p>Is there an echo in here?</p>

$count -- Just a variable

switch -- A switch statement. Seriously, if you don't know what a switch statement is, go learn some basic coding.

case -- The cases to the switch statement. For example:
Code:

$number = 1;
switch($number) {
case 1: echo("Number is 1"); break;
case 2: echo("Number is 2"); break;
}

So then if you try that, on the webpage, it would say "Number is 1".
rvec
Raidation wrote:
include -- To make website design easier. You load a text or php or whatever file and it replaces the include statement with whatever is in that file. Like for a menu. Without include, you would need to manually add a button to each page. With include, you would only need to change the file you include.

echo -- Just to show something on the webpage. For example, echo("Is there an echo in here?"); would be the html equivalent to <p>Is there an echo in here?</p>

$count -- Just a variable

switch -- A switch statement. Seriously, if you don't know what a switch statement is, go learn some basic coding.

case -- The cases to the switch statement. For example:
Code:

$number = 1;
switch($number) {
case 1: echo("Number is 1"); break;
case 2: echo("Number is 2"); break;
}

So then if you try that, on the webpage, it would say "Number is 1".


It would be a waste to only use include for design. It can also be used to include scripts, classes and libraries you need to make a function work. By keeping different functions in different files you can keep your site organized and use the same function on more page or replace it with similar stuff easily.

Echo has no html equivalent, everything you put in echo is send to the output. HTML is a markup language for the output. In normal web scripts you can look at echo as the command to send data to the webpage.

Everything starting with a $ is a variable (there are possible exceptions, but they are baad).
JosexD
where should the included files be located ? at the same folder as the *.php ?
ty
imagefree
JosexD wrote:
where should the included files be located ? at the same folder as the *.php ?
ty


A file can be included from anywhere inside the server. For example if your script is ar dir1/dir2/script.php you can include a file dir1/script.php etc.


A file needs not to be of the extension .php for includion. YOu can include .ini .css .php .abcdedfgh otc or even a file without any extension. Included file if contains the php opening and closing tags, anything inside those tags is considered as php script, and anything outside those tags is simply thrown to browser.
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.