警告:implode():在加载页面传递的参数无效

My script load a title of url when this load by php_self in a html form.

<?php
$bk_url=$_REQUEST['bk_url']; 
$remote_url = $bk_url;
$from_remote_url = implode("", file("".$remote_url));
if(preg_match("/<title>(.+)<\/title>/", $from_remote_url, $regs)) {
} else {
echo "<br> Title empty. Manual insert";
}
?>

When load the php page, are displayed two errors:

Warning: file(http://): failed to open stream: operation failed

and this error:

Warning: implode(): Invalid arguments passed

I have try to find a solution on stackoverflow but not find any solution.

How to fix this two errors? Thanks

You need to run the code only when the user has submitted the form. So check first to see if the variable is set.

if (isset($_REQUEST['bk_url'])) {
    $bk_url=$_REQUEST['bk_url']; 
    $remote_url = $bk_url;
    $from_remote_url = implode("", file("".$remote_url));
    if(preg_match("/<title>(.+)<\/title>/", $from_remote_url, $regs)) {
    } else {
        echo "<br> Title empty. Manual insert";
    }
}