Forum Moderators: open

Message Too Old, No Replies

HTML vs. PHP

how to learn php very quickly

         

Mr_Cat

7:09 am on Oct 2, 2008 (gmt 0)

10+ Year Member



Hi folks,

I've been 'off the scene' for quite some time and I'm just getting back into it having been asked to do a bit of charity work.

I need some basic content up quick. I would like to get to grips with php and am wondering on the best available 'beginners guide' out there for getting basic results pronto? I have the feeling I should just code up some html pages and then work on a php version for later perhaps, but I'm not sure yet. I have glanced over a few php pages and it looks like it ought to be pretty simple to achieve a few basic pages maybe as quick as I could in html which I already know. Maybe I'm also slightly mistaken in assuming that php effectively 'replaces' html as a language of sorts?

Sadly time is of the essence and I son't have a huge ammount on my hands these days.

Cheers
Mr Cat

daveVk

7:24 am on Oct 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



w3schools [w3schools.com...] probably as good as anywhere

g1smd

7:53 pm on Oct 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



PHP doesn't replace HTML.

The PHP script is used to output a page of HTML, some elements of which have been built as a result of programmatic decisions within that script.

The most useful PHP feature is INCLUDE files. It allows the "page" to be built from chunks of code, and for single chunks to be re-used in multiple pages of the site over and over again.

That allows site-wide changes to be very rapidly implemented. The usage of CSS for styling is crucial. Separation of content and style, once you cross that bridge, opens a whole new way of thinking - you won't go back.

thecoalman

12:35 am on Oct 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



To expand on g1smd's post php is programming language built for making HTML pages. It can also interact with a database back end.

For example your php page might contain something like this with HTML and PHP mixed:


<html>
<head>
<title>Some Title</title>
</head>
<body>
<?php
include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php');
>?

<p>Some content</p>

<?php
include($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php');
>?

</body>
</html>

The server simply outputs the first part as text until it hits the <?php where it switches to php mode. In this case its going to include a file called header in a folder called includes.

Whatever is in header.php is executed or outputted. You might for example want to inlcude all the basic header and navigation for your site here. To change the navigation site wide you only have to edit one file.

Although a great feature it's really one of the most simplistic ways you can use php . As mentioned its a programming language which opens all kinds of doors, the possibilities are endless.

The full manual can be found here: [php.net...]

g1smd

11:30 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I say start with the simple: PHP includes, dynamic breadcrumb navigation, and then once you see what is possible, be working on a better version offline (install Apache and PHP on your local PC and develop at http://localhost/), which will eventually replace the "basic" site.