I heard people said php server site script cannot communicated with html and javascript client-side script. But when I test it, seem php can tell html and javascript what to do. Here is my codes :
<?php if ((isset($username1))&&($username1 == $username2)){ ?>
<div style="position:relative;">
<img src="http://plekz.com/images/layouts/theme.png" onClick="showThemeDiv(); hideThemeTip();" style="margin-bottom:3px; margin-left:1px; position:relative;" onMouseOver="showThemeTip();" onMouseOut="hideThemeTip();" />
</div>
<?php } ?>
I tested it on IE, Firefox and Chrome, all works perfectly. But I still worry code this way will lead to problem when I move all the file to other online webhosting/server… Do I need to put all html and javascript codes into php echo? Or I can just code like this without having any problem in future? Is it standard way to code like this?
What you are doing is just PHP, in your code there is no actual communication between “html and javascript”, which is on the client’s side. And PHP, which is on the server side.
What people mean with communication is that the user can change something on the webpage dynamically without reloading the webpage. Such a thing can be done using
AJAX.In short, the code you are using will work on any webserver and with any browser.