Error using return in PHP
Answer
In the use of such as Mysqli_conn, as long as there are "I" statements will be wrong, I loaded the latest version of PHP.
In a function, a return $db is used and an error occurs.
What's going on?
Best answer [URL=HTTP://WWW.PHPCHINA.COM/BBS/SPACE.PHP?USERNAME=YAFEIKF] link tag Yafeikf[/url]
[url=http://www.phpchina.com/bbs/space.php?uid=38739] link marker [img]http://www.phpchina.com/server/avatar.php?uid= 38739&size=small[/img][/url] because the foundation is not well-played.
MySQL and mysqli are both MySQL for PHP connection extensions. There are only two reasons for the error, 1: There is no installation of the mysqli extension; 2: Parameter usage error or database information error
What are you going to return? If a function function a ()
{
function is a separate piece of the day. There is no $db this variable at all in function. Where did you return from?
return $db;
}
Copy Code
Other Solutions
Because the foundation is not well-played.
MySQL and mysqli are both MySQL for PHP connection extensions. There are only two reasons for the error, 1: There is no installation of the mysqli extension; 2: Parameter usage error or database information error
What are you going to return? If a function function a ()
{
function is a separate piece of the day. There is no $db this variable at all in function. Where did you return from?
return $db;
}
Copy Code
Other Solutions
Well, I think it might not have opened the extension
Other Solutions
You sent out the code.
It's not clear how it looks.
Other Solutions
Thank you! It's mysqli not open.
But return is still a mistake.
function Db_connect ()
{
@ $db = mysqli_connect (' localhost ', ' root ', ' 8251617 ', ' bookmarks ');
if (! $db)
{
throw new Exception (' Could not connect to database server ');
}
Else
{
return $db;
Echo ' dddd ';
}
}
The above code, such as remove return can pass, but I need return value AH.
}
Other Solutions
[url=http://bbs.phpchina.com/redirect.php?goto=findpost&pid=1073261&ptid=128738] link marker 3#[/url] Kazaff
Thank you 1
Other Solutions
All operations after return do not continue
Other Solutions
[url=http://bbs.phpchina.com/redirect.php?goto=findpost&pid=1073310&ptid=128738] link marker 7#[/url] yafeikf
The problem is: as long as there is return in the code immediately out of HTTP 500 error, the page can not be found, and the previous mysqli out the same mistake, there is something not open?
Thank you
Other Solutions
Did you install the Xdebug?
After a similar problem, you can use it to chase
Other Solutions
There seems to be a problem with the code.
http://www.bkjia.com/PHPjc/632379.html www.bkjia.com true http://www.bkjia.com/PHPjc/632379.html techarticle use return error in PHP the answer is to use such as Mysqli_conn, as long as there is an "I" statement will be wrong, I loaded the latest version of PHP. In a function, the return $db is used and an error occurs .