Page 1 of 1

php script ?

Posted: Fri May 07, 2010 5:21 pm
by kareem100
Hi,

I'm learning php at a local college.

I have wriiten some php files whose first line is <?php .

I've just written a php file whic has a lot of header information ( it has keywords - <head>, <title>, <body> etc etc )

Am I right in assuming one of them is a php script and the other is a full php file.

Regards,
Kareem

Re: php script ?

Posted: Fri May 07, 2010 5:44 pm
by yacahuma
the placemente of the <?php is irrelevant. You use it anywhere you need to add the php code

Re: php script ?

Posted: Fri May 07, 2010 7:59 pm
by califdon
kareem100 wrote: I'm learning php at a local college.

I have wriiten some php files whose first line is <?php .

I've just written a php file whic has a lot of header information ( it has keywords - <head>, <title>, <body> etc etc )

Am I right in assuming one of them is a php script and the other is a full php file.

Regards,
Kareem
First of all, congratulations on taking formal instruction. It's not the only way to learn, but it's a good one for anyone who can spare the time.

No, all those <head> ... <body> are HTML tags. That's what the browser receives and interprets, to display the page. PHP is the server script that can process an HTML file before it is sent to the browser. There is no difference between a PHP file and a PHP script. As yacahuma said, PHP code can be the entire file, or it can be inserted in the middle of HTML, or anyplace it is needed, in order to generate the ultimate document that the browser receives. The <?php and ?> are the beginning and ending of any section of PHP code. That's how the web server knows what to process as PHP code.

Start by understanding HTML. If there is no PHP code at all, the web server sends an HTML file to the browser and the browser interprets and displays the document. If you need to have dynamic content, like maybe something from a database on the server, you insert PHP code in the document file (between <?php and ?>) to connect to the database, find the desired data, and add it to the HTML that may already be in the file. So the PHP code could be just one tiny part of a file, or it could be several parts of a file, or it could be the entire file.

Re: php script ?

Posted: Sat May 08, 2010 5:12 pm
by kareem100
Hi,

Yes that makes sense .

Regards,
Kareem.