File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes PHP and the fly likes Simple Question about PHP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Languages » PHP
Bookmark "Simple Question about PHP" Watch "Simple Question about PHP" New topic
Author

Simple Question about PHP

santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
I started learning PHP to create a simple website i'm planning.
I have a simple Question:



I have omitted some code to be specific about the point. The code is from chapter 13 of wrox Beginning PhP 5.3.
What i want to know is, why do we have stray "<?" tags? e.g:
Also, why is there PHP snippet after </html> tag?
I think this is a question anybody with server-side scripting can answer
Thanks
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3895
    
  18

They are not stray tags. Each ?> belongs to a corresponding <?php tag.

Inside a <?php ?> block, your php code is executed. Anything outside a php block is directly emitted to the resulting html.


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
Thanks Stephan.
But why is there the code snippet after </html>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63053
    
  69

To complete the block that was previously opened.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
Found this Tutorial helpful.
Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
This is html/php code which means you have to seperate the two in the code so the server knows which part of the code belongs to it and which he will pass on to the clients browser, you do that by putting php inside <?php ?> tags.
Remember php is server-side while html is client-side, what the server sees and actually matters to it is this:
pearl smith
Greenhorn

Joined: Jul 31, 2011
Posts: 3
I'm newbie in php,and i want to step my foot in,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple Question about PHP
 
It's not a secret anymore!