Home > Backend Development > PHP Tutorial > php如何与html分离

php如何与html分离

WBOY
Release: 2016-06-13 12:02:12
Original
2852 people have browsed it

php怎么与html分离
用了一个jquery上传文件的插件  uploadify,例子是php的,其他不用看,就看红色代码部分,我想把这些php代码作为.php文件来保存,然后像蓝色那样调用。我尝试着定义了a.php和b.php两个文件
a.php:
$timestamp = time();
echo $timestamp;
?>

b.php:
$timestamp = time();
echo echo md5('unique_salt' . $timestamp);
?>

然后,在html中这样调用
.......
'timestamp' : 'a.php',
'token'     : 'b.php'
.......

结果,文件上传不了。这个可能的原因是什么呢?我估计是$timestamp = time();这个,两次调用,导致不同所致。

像下面php和html混杂这种方式,$timestamp = time();就只执行了一次。

有什么方式让a.php和b.php用一个$timestamp?多谢指点先。

nbsp;HTML>



UploadiFive Test
<script></script>
<script></script>





Uploadify Demo







<script><br /> <span style="color: #FF0000;"><?php $timestamp = time();?><br /> $(function() {<br /> $('#file_upload').uploadify({<br /> 'formData' : {<br /> 'timestamp' :<span style="color: #FF0000;"> '<?php echo $timestamp;?>',<br /> 'token' :<span style="color: #FF0000;"> '<?php echo md5('unique_salt' . $timestamp);?>'<br /> },<br /> 'swf' : 'uploadify.swf',<br /> <span style="color: #3366FF;">'uploader' : 'uploadify.php',<br /> 'onUploadSuccess' : function(file, data, response) {<br /> alert('The file was saved to: ' + data);<br /> }<br /> });<br /> });<br /> </script>


------解决方案--------------------
继承父类或者使用include包含
楼主直接把'formData'     : {
'timestamp' : '',
'token'     : ''
},
这个验证参数去掉,没什么用就是个时间验证
------解决方案--------------------
php变量在js里面是没办法分离,就算用到模板,只是换了一种显示格式而已。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template