我找不到解决办法。所有我想做的是获取和执行一个url/链接存储在我的数据库中的记录。我不希望它作为一个链接返回,而是一个页面从这个url/link php.
尝试使用函数…
您需要从数据库中获取链接,然后使用此函数获取内容
<?php
$con = mysql_connect('localhost','username','password');
mysql_select_db('database_name');
$sql = "***`<select query here>`***";
$res = mysql_query($sql);
$row = mysql_fetch_row($res);
$url = echo $row['url'];
$contents = file_get_contents($url);
?>
不知道你说的"执行url"是什么意思。如果想在URL上获取数据,可以使用file_get_contents
,如下所示:
$url_content = file_get_contents('http://www.example.com/page.html');
如果你想将用户发送到那个url,你可以使用header
命令和Location
头将浏览器发送到那个地址,即
header('Location: http://www.google.com');
假设获取的变量为$fetch
。在这种情况下使用:
header("location:$fetch");