Php return error _ PHP Tutorial

Source: Internet
Author: User
An error occurred while using return in php. In php, if return is used, an error occurs when mysqli_conn is used. if I is used, an error occurs. I installed the latest php version. in a function, an error occurs when return $ db is used. how to use return in php?
Answer
When using a statement such as mysqli_conn, an error occurs as long as there is an "I" statement. I installed the latest php version.
In a function, an error occurs when return $ db is used.
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 tag [img] http://www.phpchina.com/server/avatar.php? Uid = 38739 & size = small [/img] [/url] because there is no good foundation.

Mysql and mysqli are connection extensions of MySQL For PHP. There are only two causes for the error: 1. mysqli extension is not installed at all; 2. parameter usage error or database information error.

What is your return .. Assume that a function ()

{

// Function is an independent day. Function Reagan does not have the $ db variable. Where did you return?

Return $ db;

}






Other solutions
Because it does not lay a good foundation.

Mysql and mysqli are connection extensions of MySQL For PHP. There are only two causes for the error: 1. mysqli extension is not installed at all; 2. parameter usage error or database information error.

What is your return .. Assume that a function ()

{

// Function is an independent day. Function Reagan does not have the $ db variable. Where did you return?

Return $ db;

}




Other solutions
Well, I think the extension is not enabled.

Other solutions
You have sent out the code.
This is not clear.

Other solutions
Thank you! Mysqli is not enabled.
But return still has an error.

Function db_connect ()
{
@ $ Db = mysqli_connect ('localhost', 'root', '123', 'bookmark ');
If (! $ Db)
{
Throw new Exception ('could not connect to database server ');
}
Else
{
Return $ db;
Echo 'ddddd ';
}
}

In the above code, if return is removed, it can be passed, but I need a return value.
}

Other solutions
[Url = http://bbs.phpchina.com/redirect.php? Goto = findpost & pid = 1073261 & ptid = 128738] link tag 3 # [/url] kazaff
Thank you 1

Other solutions
All operations after return are not executed.

Other solutions
[Url = http://bbs.phpchina.com/redirect.php? Goto = findpost & pid = 1073310 & ptid = 128738] link tag 7 # [/url] yafeikf
The problem is: as long as there is a return in the code, an http 500 error occurs immediately, and no page can be found. The error is the same as that of mysqli. isn't anything open?
Thank you.

Other solutions
Is Xdebug installed?
You can use it to catch up with similar errors in the future.

Other solutions
It seems that the code is faulty ..


In the http://www.bkjia.com/PHPjc/632379.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632379.htmlTechArticlephp using return error answer in the use of such as mysqli_conn, as long as there is a "I" statement will error, I installed the latest php version. in a function, an error occurs when return $ db is used. how...

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.