前提・実現したいこと
file_get_contensがサーバーのセキュリティ上禁止だったのでcurlという関数で
「取り出したいデータのファイル」にある
発生している問題・エラーメッセージ
エラーメッセージ
該当のソースコード
php
1<!DOCTYPE html> 2<html> 3<head> 4 <meta charset="utf-8"> 5 <title>取り出したいデータのファイル</title> 6</head> 7<style> 8</style> 9<body> 10 11 <form method="get" action="../edit.php"> 12 <button type="submit" name="edit" value="<?php echo (empty($_SERVER['HTTPS']) ? 'http://' : 'https://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>">編集</button> 13</form> 14<div class="menu"> 15 <h1>メニュー</h1> 16 <p>カレー</p> 17 </div> 18</body> 19</html>
php
1edit.php 2<!DOCTYPE html> 3 4<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 5<head> 6 <meta charset="utf-8" /> 7 <title>別のファイルを表示したいファイル</title> 8 9</head> 10<style> 11 12</style> 13<body> 14<?php 15echo $_REQUEST['edit']; 16 17$url = $_REQUEST['edit']; 18 $conn = curl_init(); // cURLセッションの初期化 19 curl_setopt($conn, CURLOPT_URL, $url); // 取得するURLを指定 20 curl_setopt($conn, CURLOPT_RETURNTRANSFER, true); // 実行結果を文字列で返す。 21 $res = curl_exec($conn); 22 echo ($res); 23 curl_close($conn); //セッションの終了 24?> 25</body> 26</html>
回答3件
あなたの回答
tips
プレビュー