PHP Fifth course automatic type conversion and Process Control _php tutorial

Source: Internet
Author: User
Tags echo date

PHP class fifth automatic type conversion and Process Control


Study Summary:

1. Understand what automatic type conversions are

2. Understanding Basic Process Control Statements

3. Example: Implementing a Calendar Table


Automatic type conversion

1) integer-to-string
echo $num. " ABC ";


2) string-to-integer
$str +3;
3) Turn Boolean type
False case 0 "" "0" false array () NULL undefined


4) Forced type conversion
(int) $str (float) $str (string) $str




5) Constants
Define ("HOST", "localhost");

6) operator
① One Dollar
++ --


② two Yuan
= - * / %
= += -= *= /= %=
> >= < <= = = = = = = = =!==
&& | | !


③ Sanyuan
? :


Process Control:
1. Process Control
2. Functions




Process Control:


I. Branching structure
If...elseif....else
Switch...case
If the condition is a fixed value, use the switch statement


Two. Cycle control
For
While


Three. Abort the loop
Break: Direct End
 
  ";}}? >//1 2


Continue: End of this cycle
 
  ";}}? >//1 2 4 5 6 7 8 9




Tip: Exit means pause the following program
Echo Date ("W");d ate in W for day of the week
 
  

Five. Remaining parts
1.do...while

 
  {$score} ";} while ($score >=60);? >



4.99 Multiplication Table
 
  ";    }? >



3.PHP Implementation Calendar Table


Calendar table:
1. Two-layer for loop
2. Interlaced color change
3. Use the IF condition to judge
4.header Head Change Code

 
  for ($i =1; $i <= $days;) {echo ", for ($j =0; $j <7; $j + +) {if ($i > $days) {echo" ";} Else{echo "{$i}";} $i + +;} echo "";} echo "";? >

Add a background color


 
  for ($i =1; $i <= $days;) {$k ++;if ($k%2==1) {echo ";} Else{echo "";} for ($j =0; $j <7; $j + +) {if ($i > $days) {echo "";} Else{echo "{$i}";} $i + +;} echo "";} echo "";? > Abort Script 2.exit (); Abort script using    3.die ();    
 
   "; Die ("Start script abort from here"); echo "2222222";? >


http://www.bkjia.com/PHPjc/871184.html www.bkjia.com true http://www.bkjia.com/PHPjc/871184.html techarticle PHP Fifth automatic type conversion and Process Control Learning Summary: 1. Learn about the 2 of automatic type conversions. Understanding basic Process Control Statements 3. Example: Implement automatic type of calendar table ...

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