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


PHP what is it actually?





paul_indo
Although I have worked in HTML for a while I have not seen PHP untill coming to frihost.

I wanted to include two PHP codes in my HTML pages so I wrote them into the pages and then I just changed my "page name.html" to "page name.php".

This seems to have worked fine, but is that really all that a php page is?
A different extension on an html page?

Thanks if you can clarify for me.
DX-Blog
Basically: PHP is a scripting language with which you can make your pages dynamic. You can use it to let the user interact with your pages by making it send information to a database/file and/or retrieving information from it.

In example this forum is something which has been created with PHP, it opens a whole new world in comparisson to just HTML.
paul_indo
What I don't understand though is why the pages have to use php extensions?

If I use java scripts they run on an HTML page but the php scripts will only run on a page with extension .php.

Is this something to do with the PHP software that runs on the server or something like that?
JayBee
Thay are using PHP extension because:
the web server want to know what files are php script and then "execute" them

so javascript is client side scripting method
and PHP is server side, so no PHP code is transeferd to browser - you can hide your programming techniques and your tricks

JS is faster
php can bring you many features, that JS can't

eg, you can make easy template engine and include header menu and footer to all pages
BearClaw
JayBee wrote:
JS is faster


That is incorrect. Since php is a server side language, the code gets executed before it gets to the client. JS execution speed depends on how fast the client's computer is since it is executed at the browser level.

PHP stands for Hypertext PreProcessor which essential means the above. The .php extension allows for the server to identify which files need additional processing prior to export to the client and which files need access to the php libraries and functions.

PHP is primarily used for data handling/processing where as java/javascript should be used for graphics or low level data processing that may be needed on the client side.
izcool
This here is a PHP/HTML page that I've scripted not that long ago :

Code:
<?php $section = "Links";
if(!file_exists("layout.inc.php")){exit("Error :  Header File Missing");}else{include_once("layout.inc.php");}
$layout->head();

// PHP Script Source Code "links.php". Copyrighted (C) 2005 Izcool Entertainment. //
// Izcool Entertainment Links File made and coded by Mike Sadowski for Izcool Entertainment. //
// This PHP script source code is copyrighted material for Izcool Entertainment and cannot be edited, altered, //
// redistributed, or taken from the Izcool Entertainment website in any way, shape, or form.  Those who //
// have legal permission from the creator of this PHP script source code are allowed to edit, //
// alter, or redistribute the PHP script source code. Those who break the script rules are //
// subject to be prossecuted to highest extent of the law. //
// These comments MUST NOT be removed. //

// Start Links Source Codes //

if($_GET[id]){

$query1 = mysql_query("SELECT * FROM o_links WHERE id='$_GET[id]'") or exit($_DB[dberror] . mysql_error());
$query2 = mysql_fetch_array($query1);
$query3 = mysql_num_rows($query1);

if($query3 == "0"){header("Location: $_SETTINGS[maindir]$_SERVER[PHP_SELF]");$layout->foot();exit;}

mysql_query("UPDATE o_links SET clicks=clicks +1 WHERE id='$_GET[id]'") or exit($_DB[dberror] . mysql_error());

header("Location: $query2[url]");

}else{

$query1 = mysql_query("SELECT * FROM o_links ORDER BY RAND()") or exit($_DB[dberror] . mysql_error());
$query2 = mysql_num_rows($query1);

if($query2 == "0"){
echo"<center>Sorry, but there are currently no links.</center>";
}else{

echo"These are some of the websites that we go to when we're really supposed to be working.  We listed them here because we thought that you would take interest in them also.
<ul>";

while($query3 = mysql_fetch_array($query1)){
echo"
<li><a href='$_SETTINGS[maindir]$_SERVER[PHP_SELF]?id=$query3[id]' target='_blank'><b>$query3[url]</b></a> - $query3[descr]<br><br>
";
}
echo"</ul>";
}
}

// End Links Source Codes //
$layout->foot();
?>


Actual link to the code above : http://www.izcool.be/links.php (Proudly hosted on FriHost !!) Very Happy

Obviously, there is a huge difference between HTML and PHP. I have HTML embedded into my PHP code for when that part of the code gets broadcast to the client (depending on what statements match, etc).

If you try to put that page on your site, it will probably more than likely not work since I've programmed it specifically to work with the files that are on my website. With some editing, you can probably make it work with your website.

Just to give you an idea of what PHP looks like.

- Mike.
JayBee
BearClaw wrote:
JayBee wrote:
JS is faster


That is incorrect.


I mean, that JS is faster for some page generation than new query to server
and for example validation of FORM data is more efficiant by JS first and than with PHP script.

Nowaday machynes are "faster" then server that executes many queries per minute. So using of JS can speedup response.
burningjacks
first off...that guy is really good with PHP and im jealous. i have been trying to learn it for some time.

i heard that php can load your and collect cookies so it wont have to reload it....instead of using a frame you just have the tables n banners all on every page does anyone know the code for that?
izcool
burningjacks wrote:
first off...that guy is really good with PHP and im jealous. i have been trying to learn it for some time.

i heard that php can load your and collect cookies so it wont have to reload it....instead of using a frame you just have the tables n banners all on every page does anyone know the code for that?


Don't be jealious. My entire site is programmed in PHP along with several others that I've done. I learned PHP (believe it or not) by downloading codes from http://www.hotscripts.com/ that people make, read them, and pick out commands that I wanted to experiment with. I made an entire game site out of PHP that I sold (it's niglected now, with the new owner) which took me several years to complete - http://www.giropets.net/ . I didn't learn overnight you know, it took quite awhile before I got to be good at it. Many codes I've done are well over 1,000 lines long, which take me a couple of weeks to complete by hand. BTW, I use Notepad for my editor, I don't use any other. It's as simple as I am and Notepad is as simple as it needs to be for my usage.

- Mike.
BearClaw
you would use setcookie() before the header of the html code. setcookie() has to be processed before any output for it to work. then when you want to call the cookie you simply use the global identifier...$_COOKIE['cookiename'] i believe just going from off the top of my head.
natut
Quote:
What I don't understand though is why the pages have to use php extensions?

If I use java scripts they run on an HTML page but the php scripts will only run on a page with extension .php.

Is this something to do with the PHP software that runs on the server or something like that?


PHP extensions (associations) can be changed on the httpd.conf of your apache server (i do not know with other server). with this you can associate ANY extension to php. But be VERY cautious in doing this because you might step on somebodys toes! Smile

Extensions are NEEDED to identify things (so that the server know what to do with these files)
shabda
Quote:
BTW, I use Notepad for my editor, I don't use any other.

But would you really advise others to do the same? If nothing else at least code coloring is useful. I mean dont use Wyswyg editors, but notepad, thats a bit too much.
frozenhead
PHP (Hypertext Preprocessor)

Mainly, it's a server-side scripting language where you can do almost everything regarding Web Applications.

The good thing about this scripting you can test your scripts even if not using a web browser. An example is testing "Cron jobs of server-side scripts in a command line (MS-DOS)" to be specific.

Other Info's for this scripting languages. Here's a link. www.php.net
dac_nip
"BTW, I use Notepad for my editor, I don't use any other" woah, that's a bit too much for me. I use quanta or bluefish. Your eyeballs will get out of their socket if you use notepad as your editor! so this means that your using windows to do scripting in PHP? im better of with linux, establish a LAMP setup and you can basically do anything in the web. PHP has a very good documentation (www.php.net), every function details and stuff are there. so if you really want to learn PHP, just go to their site and experiment! ole. Laughing
yjwong
At the least use Notepad++.
mathiaus
i think we've established what it is now Wink
-close-
Related topics
Visitor ip PHP (E107)
[tutor] How to protect images without htaccess using PHP
PHP Validation Class
Php-nuke comments pending
Implementing your database access in PHP as a layer.
Mail with PHP (Simple Tutorial)
[PhP] News Posting Tutorial (code, actually ^^')
Dreamweaver
Building Web Forms In Flash
what is dump?
Avatars
Apache mod_rewrite
Learning PHP
Code the Iphone why?
New to programming, which language do I choose?
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

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