This is really time-consuming-PHP Basics (3)

Source: Internet
Author: User
Tags php basics
This is really time-consuming-PHP Basics (3) hi

I have just read the Chinatown case, and I have received 5 stars. Since it was a long-time appointment, it is not easy to give up (although it is a man...), but it is still necessary to write time. My instructor's project will be closed tomorrow morning. although it has little to do with me, don't mess up !!

1. PHP

I. PHP Basics (III)
1.3.2 Int

Integer.

Points:Hexadecimal problems(2, 8, 16 );

Overflow: automatically converted to float type after overflow;

Division;

Float to int -- rounded down;

Example

$ Shi = 123;
$ Bin = 0b100001;
$ Ba = 0123;
$ Shiliu = 0x1234555;

Function show ($ ){
Echo "Truth is :";
Var_dump ($ );
Echo"
";
}

Show ($ shiliu );
Show ($ ba );
Show ($ bin );

$ Qiguaideba = 01237823; // The "overflow" of the octal block will be truncated and only 01237 will be output.

Show ($ qiguaideba );

Function zhengchu ($ a, $ B ){
$ C = $ a/$ B;
If (is_float ($ c )){
Var_dump (round ($ c); // use round to control the output result
} Else {
Var_dump ($ c );
}
}

Zhengchu ($ shiliu, $ ba );

1.3.3 float

Different php versions make the precision of floating point changes,Due to the internal mechanism of PHP, the following may occur:

Var_dump (floor (0.1 + 0.7) * 10 ));

The returned result is usually 7 instead of the expected 8 ....

If high precision is used,Use gmp functions, Please learn about it yourself...

If you really want to compare themSet a minimum valueTo compare:

$ Bijiao1 = 0.232342342;
$ Bijiao2 = 0.232342323;
$ Esp = 0.000001;
If (abs ($ bijiao1-$ bijiao2) <= $ esp ){
Echo "True "."
";
} Else {
Echo "F ** k "."
";
}

1.3.4 string

Enclosed in single double quotes ~

Then I just want to talk about heredoc:

$ Str = <EOF
Alsidjflja
Akjsdhflkj
Dfjlkj.
EOF;

Echo $ str;

This is basically the case, but note,The EOF in the last line must be closely related to the semicolon, and the end of the semicolon must be a line break. the front of the EOF cannot contain spaces;

Then heredoc can be used to pass parameters and initialize static values;

Of course, in heredoc, you can also call the parameters, attributes, or something-think of EOF as a large double quotation mark.

Other string-related features, such as connectors that I often use, are relatively basic, but easy to use. you can see the video clearly.

Nowdoc is also a relatively new method, not familiar with it, and then it seems to be equivalent to single quotes.

1.4 Variables

Variables are easy to use, variables are flexible, and variables are difficult to use.

First, PHP does not emphasize initial values and does not need to be declared. HoweverRecommend or assign initial values to form good habits; If no initial value is assigned, the variable value is the default value of its type;

Second, you must know that $ B = & $ a; can only operate on variable names;

Third, the assignment is updated once:

$ Shit = "asdf ";
$ S = 123;

Echo $ shit;

$ Shit = $ s;
Echo $ shit;

2. implement image watermarks and thumbnails in the GD Library

I. INTRODUCTION

Use the self-contained GD Library in PHP to create image watermarks.

It is suitable for simple processing of large batches of images.

Learn the basic methods and encapsulate them into a tool class.

In addition to watching Star Wars this weekend, I just made up for it. I know it's wrong .....

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.