how to write a php embed code that calls another php in a html page
7
How to write a PHP code (using public id) that can embed into HTML file (abc.html) when we open that HTML file that has to call another PHP file(there we can insert stats of that file into database).
if i cannot do this in php, is there any other way except renaming html file extension to php extension
Answer
Solution:
Do you mean this?
or
using
exec('php foo.php');
to call another php file?or
including another php file using
EDIT:
Or you can use ajax to call a .php file to the abc.html file.
You need to have the jquery library which can be downloaded here.
Answer
Solution:
If I understood you correctly, you're wanting to use the PHP include function. You may also want to check PHP's include_once function depending on what you're doing.
You will need to make sure the "HTML" page is actually a PHP page. If your page is already written and exists as HTML and not PHP, you will need sufficient privileges to edit the MIME types and associate .html (or whatever file extention you're using) with PHP processes on the server side. Otherwise you will need to recreate the page as a PHP page using the .php file extension.
For example you may have code like this in the initial file:
This will call the this_page.php file and allow it to execute any scripts within it.
I hope this helps you.
Answer
Solution:
You cannot embed PHP into an web page, PHP is a server side scripting language, which means it is only executed on the server. The user does not even know whether you are using PHP (except for the .php extension, but that means nothing.)
You can however call a PHP script from another PHP script, e.g.
Answer
Solution:
include(other_file.php), include_once(other_file.php), require(other_file.php), require_once(other_file.php) ...
or
use an iframe or exec(other_file.php)
Answer
Solution:
Within your HTML you could use a tag such as an image or script to call your php script. This could be useful if you want your PHP to do something simple such as to increment a counter in a database.
This is trivial as long as you don't want the executing PHP to return anything visible within the page. If you use an image tag, after you've finished with whatever processing you are doing, it might be best to have your PHP return an image of some sort - but it could be as trivial as a 1px by 1px transparent gif.