Third object operator notice prompt-php Tutorial

Source: Internet
Author: User
Third-order operator notice prompt
$act = isset($_POST['act']) ? $_POST['act']:(isset($_GET['act']) ? $_GET['act']:'login');


Why must the last three orders operator in the code be enclosed in parentheses? If not, a notice error occurs.


Reply to discussion (solution)

There is no such phenomenon

Notice: Undefined index: act in C: \ Users \ John \ Desktop \ shop \ admin \ privilege. php on line 3


At least you didn't reflect this.

What's going on? How can I report a notice?

You mean me #3?
The second line $ act is used directly without assigning a value (echo $ act;). it is necessary to report notice.
However, the third line does not contain the parentheses you want to add, but does not report the notice

I am doing this to prove that I have not blocked notice-level errors.

I also didn't use @ blocking errors. how can I add brackets without naotice errors or parentheses.

No problem.
It is estimated that the code you provided is incomplete. the notice is from other places.

 

I still don't know the reason. without parentheses, notice says this variable is not defined. I have var_dump and The act also has data:
Array (4) {["act"] => string (6) "signin" ["username"] => string (0) "" ["password"] => string (0) "" ["captcha"] => string (0 )""

I changed it to this.

$act = isset($_REQUEST['act']) ? $_REQUEST['act']:isset($_REQUEST['act']) ? $_REQUEST['act']:'login';


Unified $ _ REQUEST

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.