Using return Error in PHP _php tutorial

Source: Internet
Author: User
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 .

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.