Thursday, 15 August 2013

Using PHP in a .html document -



Using PHP in a .html document -

i'm working on job @ work need create web forum. in stupidity decided utilize javascript, not knowing beforehand javascript client-side language. need way save info javascript onto server , able read data. tried looking @ things node.js, have reconfigure entire web server (which isn't mine) in order this. other solution utilize php. here's problem: there's bunch of includes used in html file set layout of webpage (i.e. css files, html files, , php include). can't alter name of index file index.php because breaks of includes within of file. need way save, text file, using javascript , html. if there's way to, simple, include php file in html , phone call php function in javascript code contents of file index.html page. thought there way phone call simple command this:

<script> var thedata = <?php getdata() ?> </script>

where php function getdata() homecoming json encoded string of info in (handled separate php file). there way this? other suggestions how handle info storage on server without changing index.html file index.php?

note: tried accessing apache httpd.conf file , adding handler pre-process .html files php files, doesn't seem work (nothing simple echo 'test' works on html file).

add .htaccess:

addhandler application/x-httpd-php5 .html .htm

source

it causes apache treat html files files contain php. careful not somehow accidentally utilize php syntax in regular html file, though.

remember you'll still need utilize php tags come in php mode. works expected:

<p>html content ... <?php echo 'hello, world'; ?></p>

but output the echo command:

<p>echo 'hello, world'</p>

php html node.js

No comments:

Post a Comment