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. Show 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.
You should also move From your updated code,
you still need to fix the quote issue. Place a semicolon at the end of the echo line. Move the
11 Years Ago In my HTML-page I am using following HTML + PHP-code: Today is: . I would expect to see: The only thing I see is: This means the PHP-code is not processed! PHP-code in a .php file works fine. Is there something wrong with my hosting-provider? (on Apache server) Please help, as I am puzzling for many days now. Recommended Answers
Jump to Post
Jump to Post
Jump to Post
Jump to Post
Jump to Post All 27 Replies
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
11 Years Ago
Hi, I checked this: Today is: . and everything worked fine. you may want to use
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
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. So it must be something
malfunctioning on the Apache-server at my hosting-provider.
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! If you send us some more examples of the code that is/isn't working, we can try and give you more specific help!
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".
11 Years Ago Hi, It is NOT so that PHP-code always must be stored into a .php-file. So there most be something wrong with the setting of the second provider. Maybe you can try it yourself with following code (Change the variables $lx01 to $lx04 to make a proper e-mail address.):
I still hope someone can tell me what .htaccess code to use to make it work.
11 Years Ago
Do this..
Edited 11 Years Ago by richieking because: n/a
11 Years Ago Today is: is just a short notation for 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.) But WHAT should I overrule? And how?
11 Years Ago
no, there is a bug in the second.
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.
11 Years Ago
My mistake in the last reaction (Oct. 6). Sorry. The real statement I'm using is: This one IS working at one provider, not on the 'bad' one's server. So adjusting the .htaccess file is the only option ... if I knew what to adjust.
11 Years Ago Look i will give you a free hosting space for a year if you want.
11 Years Ago 'short_open_tags' = On in php.ini and you can use the short tags.
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.
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.
that way you can use
Aamit -7 Posting Whiz 11 Years Agocheck 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
11 Years Ago
Thank you for your reply. Han
11 Years Ago Look speak to your hosting company. They are the best to help you. ;)
11 Years Ago
Voila!
11 Years Ago first confirm that you have save the page with '.php' extension.
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.
This tells the php5 interpreter module which file types might contain PHP code that it needs to interpret.
Save your config and restart apache, then try your html page again. The PHP should now be interpreted correctly. mikec
7 Years Ago goto : C:\xampp\apache\conf\ and add this line to "httpd.conf" : AddHandler application/x-httpd-php .html hope this works!
almostbob 866 Retired: passive income ROCKS 7 Years Agostarthosting has disabled add handler server parsed, in php.ini for their convenience just noticed the dates Edited 7 Years Ago by almostbob
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
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
2 Years Ago php code in html file not working i'm using xampp on windows10 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.
|