I am generating a KML file (which is XML formatted for a Google Map)
Within the infowindow section of the XML file is a CDATA tag.
So when the infowindow is opened on the map, the data within can be formatted with HTML tags.
Here is what I need to do. I need to have a PHP include statement within this cdata section.
I am trying to place the following within the CDATA tag,
<? include("http://www.yahoo.com"); ?>
However what I see when the page loads is:
<![CDATA[<div>
<? include("http://www.yahoo.com"); ?>
</div>
]]>
How can I get this corrected?
Thanks,
If the file has a .kml extension, you'll need to tell your web server to use PHP to serve that file extension. Something like this would do it in Apache:
AddType application/x-httpd-php .kml
If it's a .php file, my suspicion is that PHP's sort tags are disabled, and that you need to use <?php instead of <?. There's nothing really special about a CDATA tag that'd break PHP.
Related
I want to edit my php or html files on the server without logging in. I wrote a php file to import the file contents that I want to edit. The file contents will be printed in a textarea.
It does work. But, when I import a file with textarea, the browser parses the </textarea> from the file as its end part of the textarea. And the rest parts after will also be parsed, too.
Is there any methods to prevent the browser from parsing the file?
The HTML inside your textarea needs to use HTML Entities instead of the actual symbols. That way it won't be parsed.. so that's something like this:
<html> ... </html> <!-- no entities -->
<html> ... </html> <!-- entities -->
I bet there's a lot of functions that can help you with this, like htmlentities() or some JavaScript equivalent, that link leads to css-tricks where a really simple JS one is. JS doesn't have a native one, afaik.
Your PHP mustn't be executed, but as Progman stated:
When the source code is added to the content of the textarea (with
functions like file_get_contents()), it is not parsed by the PHP
interpreter. So it is not required to switch to a .html file to
prevent any PHP executions (there is none).
So, that solves this issue.
I just want to know how to put PHP into HTML5 ?
You can easily use contractions as < ?=$variable?> inside html.
There is no any difference of using php tags between html versions
First name you file to index.php instead if index.html
then you can write php wherever you want in that file..
<html>
<?php
write your php code here
?>
</html>
First you need Web server.
You can embed php code in whatever place you want inside html document, to make it run it should be delimited with <?php your_php_code ?> and save document with .php extension.
One of my file is read by php and loaded on the Web UI. But if the file contains HTML tags, it interprets and disturbs the whole UI.
How to ignore the HTML tags while reading the file contents.
I am using following code to read file contents:
readfile($name);
I think what you are looking for is htmlspecialchars function.
e.g. echo htmlspecialchars($stringFile);
If you want to strip all html tags, check strip_tags function.
I have an HTML file that has a rather long navigation menu inside of it. I want to take that menu out of the HTML and place it into an external PHP page and then call it with
<?php include 'navigation.php'; ?> in the HTML file.
I have tried just adding this into the HTML file but it doesn't display anything as well as no errors on the page.
What do I need to do (if it's even possible) to keep the files HTML and use the php require function?
Add this in in your httpd.conf and then you can process PHP code on HTML pages
AddHandler application/x-httpd-php .php .html
Q: Did you give the page a .php suffix? That should be all you need to do.
Remember the way PHP works - you basically "embed" your PHP code in an HTML page, and the server executes the PHP before it serves (the rest of) the HTML.
But in order for PHP to "see" your code, you need to make sure your "HTML page" has a .php suffix.
As a crude workaround, you can add ".html" to the list of file suffixes that PHP will parse.
But this could cause other things to break.
If you want to embed PHP code in your "index.html", the best, cleanest approach is to simply rename it "index.php".
IMHO...
I have a PHP file which might contain lot of PHP tags, scripts and HTML.
I need to get only HTML div inside the php file. The file contain lot of <?php > tags. I want to ignore those tags and to get only HTML from the page using jQuery.get().
Is it possible to do this?
When you open a .php file in your browser, the server executes the PHP files and only gives HTML (+javascipt +css) back. JavaScript is then executed in your browser and you won't have any <?php ?> tags inside. Therefore you can simply use jQuery selectors.