Html tag not working in php

You need to either escape the quotes you use if you wrap them with the same kind of quotes, or use different quotes. You should also have a semicolon at the end of the echo.

If you use the double quotes, PHP will parse the string and replace the variable with it's value. If you use single quotes you'll need to concatenate the string.

echo "
Hello, $name
"; echo '
Hello, ' . $name . '
'; echo "
Hello, $name
"; echo '
Hello, ' . $name . '
';

You should also move session_start(); to the very top of your script before there is any output.

From your updated code, you still need to fix the quote issue. Place a semicolon at the end of the echo line. Move the session_start(); to the header. You're not echoing any variable on the line so it's not necessary to use PHP to print out the HTML.

#box
{
border: 10px solid #a1a1a1;
padding: 120px 40px; 
width: 1163.5px;
border-radius: 25px;
}


Hello,
"; ?>

Html tag not working in php

11 Years Ago

In my HTML-page I am using following HTML + PHP-code:

Today is: .

I would expect to see:
Today is: monday October 4, 2010.
or something like that.

The only thing I see is:
Today is:.
(mind the dot at the end.

This means the PHP-code is not processed!

PHP-code in a .php file works fine.
Adding 'AddType application/x-httpd-php .htm .html' to the .htaccess file = no success
Adding 'addtype application/x-httpd-php .php .htm .inc .html' to the .htaccess file = no success either.

Is there something wrong with my hosting-provider? (on Apache server)
Or am I making some mistake?

Please help, as I am puzzling for many days now.

First, make sure that the file is saved with a .php extension. Then try this:

It could be that the uppercase "D"ate is causing the issue. Also, you are using short tags . Some server configurations do not allow …

Jump to Post

Just add the php to the start line. See below

I tested the code and got the following result:

Hope this helps

Max

Monday October 04, 2010

Jump to Post

1) I do NOT want to put this piece of code into a PHP-file, as I want to use php INSIDE html to mask a hard-written e-mail address to prevent spam-robots finding it. (other solutions for that are welcome also)

All PHP code must be saved within a file …

Jump to Post

You don't have to have the whole page written in PHP if it's saved as a .php file. You could have the whole page written in HTML if you wanted. Either way, the end user will never see the PHP code even if they try to view it as the …

Jump to Post

why does it not work i've tried every tutorial in the internet and it did not work WHY

Jump to Post

All 27 Replies

Html tag not working in php

11 Years Ago

First, make sure that the file is saved with a .php extension. Then try this:

It could be that the uppercase "D"ate is causing the issue. Also, you are using short tags . Some server configurations do not allow this. Instead, always use the full tags

Html tag not working in php

11 Years Ago

Hi, I checked this:

Today is: .

and everything worked fine. you may want to use

Html tag not working in php

11 Years Ago

Just add the php to the start line. See below

I tested the code and got the following result:

Hope this helps

Max

Monday October 04, 2010

Html tag not working in php

11 Years Ago

Thank you all for your reply, but ...

1) I do NOT want to put this piece of code into a PHP-file, as I want to use php INSIDE html to mask a hard-written e-mail address to prevent spam-robots finding it. (other solutions for that are welcome also)

2) All options given are already tested and not-working on the Apache-server of MY hosting-provider.
It IS working on anoter Apache-server at another hosting-provider!

So it must be something malfunctioning on the Apache-server at my hosting-provider.
I hope someone has knowledge of that kind of settings.

Html tag not working in php

11 Years Ago

1) I do NOT want to put this piece of code into a PHP-file, as I want to use php INSIDE html to mask a hard-written e-mail address to prevent spam-robots finding it. (other solutions for that are welcome also)

All PHP code must be saved within a file with a .php extension otherwise it will not be interpreted! Regardless of where it is located (e.g. nested in html). You could encrypt the email address that is hard coded, or grab the email address dynamically. There are plenty of options for this!


2) All options given are already tested and not-working on the Apache-server of MY hosting-provider.
It IS working on anoter Apache-server at another hosting-provider!
So it must be something malfunctioning on the Apache-server at my hosting-provider.
I hope someone has knowledge of that kind of settings.

If you send us some more examples of the code that is/isn't working, we can try and give you more specific help!

Html tag not working in php

11 Years Ago

You don't have to have the whole page written in PHP if it's saved as a .php file. You could have the whole page written in HTML if you wanted. Either way, the end user will never see the PHP code even if they try to view it as the browser will process the code and output the resulting HTML to the source file that they will see if they choose to "view source code".

Html tag not working in php

11 Years Ago

Hi,

It is NOT so that PHP-code always must be stored into a .php-file.
The code (stored as .htm-file) below IS Working (!) on one of my providers Apache server.
The same code is NOT working on another provider's Apache server!

So there most be something wrong with the setting of the second provider.
But they (Starthosting.nl) refuse any help.
The only thing I can do is add some option(s) in the .htaccess-file to overrule default settings.
Only ... which one?
I already added: AddType application/x-httpd-php .htm .html

Maybe you can try it yourself with following code (Change the variables $lx01 to $lx04 to make a proper e-mail address.):







New Page 1





This is a Zero Test page for testing PHP code.

There aren no links to other pages or PHP-files.

Test-code:

 

PHP without <p /p> :   Hello, today is .

PHP with <p /p>:         Hello, today is <?php echo date("l, F jS, Y"); ?>.

You can send an e-mail to: $tx"; ?>

I still hope someone can tell me what .htaccess code to use to make it work.
Thank you in advance

Html tag not working in php

11 Years Ago

In my HTML-page I am using following HTML + PHP-code:

Today is: .

I would expect to see:
Today is: monday October 4, 2010.
or something like that.

The only thing I see is:
Today is:.
(mind the dot at the end.

Do this..

In my HTML-page I am using following HTML + PHP-code:

Today is:   // This should work like a charm.

Edited 11 Years Ago by richieking because: n/a

Html tag not working in php

11 Years Ago

Today is: is just a short notation for
Today is:

None is working on Starthosting.nl, so it must be some setting in the php.ini-file owned by the hosting-provider. They don't want to change anything in that file (I think they don't know what to do.)
So the only thing I can do is overrule some php-setting(s) using the .htaccess file.

But WHAT should I overrule? And how?

Html tag not working in php

11 Years Ago

Today is: is just a short notation for
Today is:

no, there is a bug in the second.
// no good man.
syntax is wrong.
its either

 

//or
  .

and they should work fine in any server. They are both standard php short and normal tag. Not asp tags.

If this does not, then their server is not php enabled.
:)

Html tag not working in php

Html tag not working in php

11 Years Ago

no, there is a bug in the second.
// no good man.
syntax is wrong.
its either

 

//or
  .

and they should work fine in any server. They are both standard php short and normal tag. Not asp tags.

If this does not, then their server is not php enabled.
:)

My mistake in the last reaction (Oct. 6). Sorry.

The real statement I'm using is:
Hello, today is .

This one IS working at one provider, not on the 'bad' one's server.
There however PHP is installed and working for seperate .php-files.
Only Inline-PHP is not working.
And they do not want to change their php.ini settings or give any other support :((
I guess they don't know what to change.

So adjusting the .htaccess file is the only option ... if I knew what to adjust.

Html tag not working in php

11 Years Ago

Look i will give you a free hosting space for a year if you want.

Html tag not working in php

11 Years Ago

'short_open_tags' = On

in php.ini

and you can use the short tags.

Html tag not working in php

11 Years Ago

How about that. I've been using Date("l F d, Y",time()); thinking that I had to supply the time.

Learn something new everyday.

Html tag not working in php

11 Years Ago

What's the point of not saving into PHP and using HTML instead? This will slow down your system a little bit since a pure HTML code should be parsed by PHP.

I'd rather disguise my PHP file as HTML using .htaccess . Visitor will never know what's under the hood after all.

RewriteRule ^(.*)\.html$ /$1.php [L]

that way you can use
http://mysite.com/foo.html
to call
http://mysite.com/foo.php

Html tag not working in php

Aamit -7 Posting Whiz

11 Years Ago

check your php.ini setting

short_open_tag=1

Step 1: create test.php

phpinfo();
?>

check short_open_tag=1

if value 0 change to 1 or ask them(hosting-provider) to change it

Html tag not working in php

11 Years Ago

check your php.ini setting

short_open_tag=1

Step 1: create test.php

phpinfo();
?>

check short_open_tag=1

if value 0 change to 1 or ask them(hosting-provider) to change it

Thank you for your reply.
The short_open_tag is ON
Any other suggestions/options?

Han

Html tag not working in php

11 Years Ago

Look speak to your hosting company. They are the best to help you. ;)

Html tag not working in php

11 Years Ago

Look speak to your hosting company. They are the best to help you. ;)

Voila!

Html tag not working in php

11 Years Ago

first confirm that you have save the page with '.php' extension.

Html tag not working in php

10 Years Ago

In case you havent found the answer..

You probably just need to add '.html' to your apache config under the PHP5 module's settings.
Edit your httpd.conf and look for php5_module:


        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
        
                DirectoryIndex index.html index.php
        

This tells the php5 interpreter module which file types might contain PHP code that it needs to interpret.
You need to tell apache to also expect to find php in '.html' files, so just add .html to the config thusly:


        AddType application/x-httpd-php .php .html
        AddType application/x-httpd-php-source .phps
        
                DirectoryIndex index.html index.php
        

Save your config and restart apache, then try your html page again. The PHP should now be interpreted correctly.

mikec

Html tag not working in php

7 Years Ago

goto : C:\xampp\apache\conf\

and add this line to "httpd.conf" :

AddHandler application/x-httpd-php .html

hope this works!

Html tag not working in php

almostbob 866 Retired: passive income ROCKS

7 Years Ago

starthosting has disabled add handler server parsed, in php.ini for their convenience
they know exactly what they have done, and yes they refuse to change it..
it is a simple way for them to reduce their server load, NO parsing of html files for php scripts
changes cannot be made in .htaccess, that too is disabled.
BUT: filename changes have not been disabled in php.ini, you can set up displaying .php files as .html extension in .htaccess, so the user will see file.html but the server will parse file.php

just noticed the dates
AAAAHHH CRAP, why did that idiot wake up a two years dead thread and waste my bloody time

Edited 7 Years Ago by almostbob

Html tag not working in php

5 Years Ago

mutiple text boxes added thru add button insert these values each rows in mysql database ie each value insert each in table

Html tag not working in php

2 Years Ago

why does it not work i've tried every tutorial in the internet and it did not work WHY

Edited 2 Years Ago by FoxyLourd YT

Html tag not working in php

2 Years Ago

php code in html file not working i'm using xampp on windows10
helpppp plzzzzzzzzzz

Reply to this topic

Be a part of the DaniWeb community

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

Why PHP is not working in HTML?

The answer is in fact so simple you would want to bang your head: Simply change the file extension from ". html" to ". php"!!! Remember that you can build a webpage entirely out of PHP and all JavaScript and stuff built off JavaScript like, JQuery, bootstrap, etc will work.

Can we use HTML tags in PHP?

As you can see, you can use any HTML you want without doing anything special or extra in your PHP file, as long as it's outside and separate from the PHP tags. In other words, if you want to insert PHP code into an HTML file, just write the PHP anywhere you want (so long as they're inside the PHP tags).

How do I get PHP to work in HTML?

When it comes to integrating PHP code with HTML content, you need to enclose the PHP code with the PHP start tag php and the PHP end tag ?> . The code wrapped between these two tags is considered to be PHP code, and thus it'll be executed on the server side before the requested file is sent to the client browser.

How do you put a PHP tag in HTML?

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the PHP. Step 2: Now, we have to place the cursor in any tag of the tag where we want to add the code of PHP. And, then we have to type the start and end tag of PHP.