PHP - Javascript integration?
PHP - Javascript integration?
假设你在一个php文件中,你想运行一个同时包含javascript和php的javascript函数。你将如何做到这一点?例如:
<?php
<script>
function myFunction(){
// php code
document.write("Hello World!");
}
</script>
?>
我知道我可以很容易地为这个特定的代码制作一个php函数,但只是为了将来参考,我想知道如何做到这一点。
如果以前有人回答过这个问题,我很抱歉,但在谷歌搜索中似乎很难用词。
PHP代码必须输出javascript内部有效的文本。像这样的东西。
<?php
<script>
function myFunction(){
// php code
var message = "<?php echo "My alert message"; ?>";
window.alert(message);
}
</script>
?>
相关文章:
- Kendo-knockoutjs integration
- PHP - Javascript integration?
- PHP and Jquery integration
- Meteor - Ckeditor Integration
- Pusher Integration
- Integration Virtualscroll.js
- Integration PHP + Javascript
- Node JS with C++ integration
- HTML5 and facebook integration
- Shopify + Mixpanel Integration
- 为什么我在尝试使用 StageWebView 在 AIR Android 应用程序中实现 Google Maps Jav
- Angular.js integration with Ruby On Rails Forms
- WebRTC and WebAudio Integration
- Integration with LAMP
- Jquery spritespin integration with angular js
- 是 var { route, redirect, routeHandler, Link } = router;在 Jav
- Angular JS and Oauth 2.0 Integration
- 如何仅针对某些情况(如特定于Internet Explorer的CSS或特定于Internet Explorer的Jav
- Understanding Vertical Movement Method in "Eloquent Jav
- jquery.js / whmcs integration