我有一个包含以下js函数的index.php文件:
function returnImageString() {
return "<?php include 'inc/image.functions.php'; echo getRandomImages(7); ?>"; //This isn't dynamic; this will always return the same images. How do I fix this?
}
然而,当页面加载时,php脚本被调用并将结果添加到源代码中,如下所示:
function returnImageString() {
return "images/20.11.A1B9.jpg|images/8.14.47683.jpg|images/19.10.FBB9.jpg|images/21.12.9A.jpg|images/8.11.1474937909.jpg|images/8.15.99404.jpg|images/8.10.jpg|"; //This isn't dynamic; this will always return the same images. How do I fix this?
}
我的要求是每当我调用js函数(returnImageString)时,它都要调用php函数(因为php函数返回随机图像位置的字符串),而不是在js函数中硬编码字符串。
有人能指点我吗?谢谢!