Strangely, this PHP looks all right, but it doesn't get the right result.

Source: Internet
Author: User
$screen _w = "", if ($screen _w <) {echo ' width is less than 500 ';} Else{echo ' is greater than or equal to 500 ';}


Direct echo $screen _w; can get the right result is 1366

If you judge the result is 1366 less than 500

if (int) $screen _w or intval ($screen _w)

The direct display is 0.

Harry


Reply to discussion (solution)

Is it correct to say that there is no grammatical error?

1, PHP before the execution of JS! Even $screen _w = ""; To get the data, that's when the PHP code is done.
2, $screen _w = "";
What is it? It's just a string assignment.
Even with Echo $screen _w;
It's only shown in the browser.

Var_dump print out, is a 46-bit string, JS code is also counted in the inside, with the regular number matching out to compare on it.

It doesn't seem to match, and I don't know how to get the numbers out.

I've had this problem before, and the foundation is not strong.

JS and PHP to separate,

First of all to understand which is the client's code, which is the server-side code, the two server-side code is the first execution, the client is executed after

But PHP can't get the screen width ah, I want to write a sentence to determine if the screen width is less than the main content width, it does not output a floating bar that will block the content.

These questions are almost novice, ten years as (I was no exception, hehe), why all kinds of textbooks do not write this?

  • 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.