如何使用php echo包含javascript文件? [英] How can I include a javascript file using php echo?
本文介绍了如何使用php echo包含javascript文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用php echo包含javascript文件?
How can I include a javascript file using php echo ?
我正在使用php创建一个html页面---
I am creating a html page using php ---
echo "<html><head><link rel='stylesheet' type='text/css' <script src="Calculation.js"> </script> href='style.css' </head><body>";
我在上面的行中包含了脚本代码,然后是表单标签---
I have included script code in the above line and then in form tag ---
<form action='/workdonecalculation/index.php?_pagination_off=1' method='post' class='form' onSubmit='return workdone();'>
但我的PHP代码不会调用我的javascript文件(Calculation.js)
But my php code doesn't call my javascript file (Calculation.js)
推荐答案
您没有关闭< link>
标签和 < script>
标记错误放在< link>
标记内。你还需要在 src =Calculation.js
中转义双引号,或者简单地用单引号括起来。
You didn't close <link>
tag and <script>
tag misplaced inside <link>
tag. Also you need to escape the double quotes in src="Calculation.js"
or simple you enclose with single quotes.
这是正确的代码,
echo "<html><head><link rel='stylesheet' type='text/css' href='style.css' /><script src='Calculation.js'></script> </head><body>";
这篇关于如何使用php echo包含javascript文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文