Sir,
I am having problem that when I use

<HTML>

</HTML>

and include <?php

<php?>

in between the HTML tags,

if I am saving the file with .php then I can view only the PHP tags and not the HTML tags elements.

Please tell me whether to save the file with HTML or PHP when using tags like this:

<html>

<body>

<?php


php?>

</body>
</html>

Recommended Answers

All 4 Replies

I didnt know you could end php with php?>, but it works.
Usually you just use ?>.

Whe you say explorer, do you mean the browser, Internet Explorer?

If you want php code to be evaluated when you view the file though Internet Explorer or any browser, you have to use the .php extension (by default a server that supports php will parse the file as php).
When you view the html source in IE, you will only view the html code, including the evaluated php output.

This is because the php code has been evaluated on the server and sent to your browser, IE.

If you open up the .php file in a text file directly, you will view the full source, with php tags.

I'd back that up. Have you uploaded onto a webserver? Is it PHP enabled?

to check your php capabilities create a new file called phpinfo.php

it's contents are

<?php phpinfo(); ?>

If you have php you should get a huge long list of technical stuff. If not then that's your problem.

Sarah

I want to know whether I use register_globals = OFF
it would effect the PHP code if it is included with HTML tags.

Is it advisable to use PHP in the HTML.

OR

To use a different file for PHP and another for HTML.

Ashwin Perti

I didnt know you could end php with php?>, but it works.
Usually you just use ?>.

Whe you say explorer, do you mean the browser, Internet Explorer?

If you want php code to be evaluated when you view the file though Internet Explorer or any browser, you have to use the .php extension (by default a server that supports php will parse the file as php).
When you view the html source in IE, you will only view the html code, including the evaluated php output.

This is because the php code has been evaluated on the server and sent to your browser, IE.

If you open up the .php file in a text file directly, you will view the full source, with php tags.

register globals should be off for security reasons. You'll find it hard to find a webhost that leaves them on, I reckon.

PHP scripts generate HTML pages. They aren't actually different from the end user's point of view. What is different is that the webserver has to do something to generate the HTML. In a .html page there is nothing to do but send the file.

HTML pages can't include PHP scripts
PHP scripts generate HTML pages

I would recommend that you find some tutorials for PHP and have a play with them to get used to the concepts. Read the script, then view the output source etc.

Then when it all is making sense start on your bigger tasks.

Sarah

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.