phpのexecコマンドで取得したpythonデータを
webで表示したいのですが、
Warning: Undefined array key 0 in /Applications/MAMP/htdocs/face api/index.php on line 14
といったエラーが出てしまいます。
コマンドライン上ではしっかりと取得できているのですが、
web上でのみエラーが発生します。
また、コマンドライン上のステータスコードは0で成功しているのですが、
web上でのみステータスコード127が発生します。
phpで取得したデータはwebに表示できないのでしょうか。
初心者質問で恐縮ですが、よろしくお願い致します。
php
1<!DOCTYPE html> 2<html lang="en"> 3<head> 4 <meta charset="UTF-8"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7 <title>Document</title> 8</head> 9<body> 10 <?php 11 $cmd = 'python test.py'; 12 exec($cmd, $opt, $stu); 13 print_r($opt); 14 echo "Status code was $stu"; 15 echo $opt[0] ; 16 ?> 17</body> 18</html>
python
1hello="Hello world" 2cal1=5 3cal2=5 4print(hello) 5print(cal1+cal2)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2022/06/15 10:29 編集