简体   繁体   English

我想使用 exec() 函数在我的 php 文件中运行 javascript 文件,但它出现了错误消息,我该如何解决?

[英]i want to run javascript file in my php file with exec() function, but it came up with error message , how can i fix it?

I am writing some PHP code, I tried to run JS in my php with exec() function, but after I run on web browser JS came out with error, what should I do to fix this problem?我正在编写一些 PHP 代码,我尝试在我的 php 中使用 exec() 函数运行 JS,但是在我在网络浏览器上运行 JS 后出现错误,我该怎么做才能解决这个问题?

php php

//after run below code, Javascript runtime error message shown
$response = exec("D:\xampp\htdocs\lazada.js");
echo $response;

I expected the JS could be run successfully after i run my php code on web browser我希望在 Web 浏览器上运行我的 php 代码后 JS 可以成功运行

Load the file content in the variable and print that variable in the HTML.在变量中加载文件内容并在 HTML 中打印该变量。

<?php $jsContent = file_get_contents("D:\xampp\htdocs\lazada.js");?>
<script><?php echo $jsContent;?></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从我的php文件中调用位于我的html文件中的javascript函数? - How can I call a javascript function located in my html file from my php file? 来自外部文件的 JavaScript 调用函数给出了 .is not a fuction 错误,我该如何解决这个问题? - JavaScript calling function from external file gives .is not a fuction error, how can I fix this? 如何在我的JavaScript代码中包含PHP文件? - How can I include PHP file in my JavaScript code? 当我将 JavaScript function 导入到我的 Z4C4DBAD5FCA2E78AAA47F 文件中时,如何修复无法工作的 onclick - How do I fix an onclick that isn't working when I import a JavaScript function into my HTML file 如何修复我的代码以仅在 javascript 中运行一次 - How can I fix my code to run only once in javascript 我如何从 HTML 文件中调用我的 Javascript function - How I can call my Javascript function from HTML file 如何修复 Javascript 功能以便弹出我的消息 - How to fix Javascript function so my message pops up 如何在 bash 中运行 JavaScript 文件 - How can I run a JavaScript file in bash 如何在 javascript 中运行 jar 文件? - How can i run a jar file in javascript? 我想出了一种将数字格式化为科学计数法的方法,我如何在需要时调用这个 function? - I came up with a way to format numbers to scientific notation, how can I call this function whenever I need it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM