我试图从外部PHP文件调用PHP函数到JavaScript脚本.我的代码不同而且很大,所以我在这里编写示例代码.
这是我的PHP代码:
<?php
function add($a,$b){
$c=$a+$b;
return $c;
}
function mult($a,$b){
$c=$a*$b;
return $c;
}
function divide($a,$b){
$c=$a/$b;
return $c;
}
?>
Run Code Online (Sandbox Code Playgroud)
这是我的JavaScript代码:
<script>
var phpadd= add(1,2); //call the php add function
var phpmult= mult(1,2); //call the php mult function
var phpdivide= divide(1,2); //call the php divide function
</script>
Run Code Online (Sandbox Code Playgroud)
所以这就是我想要做的.
我原来的 PHP文件不包含这些数学函数,但想法是一样的.
如果有一些它没有一个合适的解决方案,那么请你建议一个替代方案,但它应该从外部PHP调用值.
谁能解释为什么这段代码在简单的 println 语句中给出错误?
fn set() -> String {
String::from("Foo")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn set() {
println!("{:?}", set());
assert!(true)
}
}
Run Code Online (Sandbox Code Playgroud)
给出以下错误
thread 'tests::set' has overflowed its stack
fatal runtime error: stack overflow
Run Code Online (Sandbox Code Playgroud)