Jump to content

PHP in Javascript?


Cetanu

Recommended Posts

PHP is executed on server. JavaScript on the client side (which usually means the browser).

 

So... no... not really. You can however use AJAX to communicate JavaScript in the browser with PHP on the server.

 

Okay, I'll go look into some AJAX. Thanks. :)

Link to comment
https://forums.phpfreaks.com/topic/176890-php-in-javascript/#findComment-932689
Share on other sites

You can actually do this... you would have to use AJAX to make things change, but you can certainly pull data from a database and put it inside javascript code so that when the server loads the page it is there....

 

<?php

 

// go get data from server..

//all html code and crap here

 

echo '<script>alert("'.$dynamicDataHere.'")</script>';

 

// ending html crap here

 

?>

 

That is not to say that it can be changed dynamically with php (without the use of ajax).

Link to comment
https://forums.phpfreaks.com/topic/176890-php-in-javascript/#findComment-932701
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.