Basic PHP Learning

Source: Internet
Author: User

Basic PHP Learning

<?php

Type

$test = 123;

Var_dump ($test);//print out type and value

Echo '

echo GetType ($test);//get variable type-"integral type"

Echo '

$res = (bool) $test;//temporary conversion type

Var_dump ($res);//true

Var_dump ($test);//123

Echo '

Settype ($test, ' string ');//change type

Var_dump ($test);//"123"

Echo '

Assign value

Var_dump (

0== $sdfg//null-->0 1+NULL;//1

);

$i = 5;

$i + +;

Echo $I;//6

Echo '

Character connections

$str 1= "Hello";

$str 2. = $str 1; $str 2=null. $str 1;

$str 2. = '! '; $str 2= $str 2. '! ';

Echo $str 2; Hello!

logical operators and && and; or;! Non -

$i = 1;

$j = 0;

Var_dump (

$i && $j//false

$i--&& $--j//true

);

?>

@ Error Suppression symbol, suppressing error output

$var = 1;

@settype ($var, ' King ');

echo @ (4/0);

Die exit: Terminate program execution

Output 99 multiplication table

For ($i =1; $i <=9; $i + +) {

For ($j =1; $j <=9; $j + +) {

Echo "{$i}x{$j}=". ($i * $j). ' ";

}

Echo ' <br/> ';

}

Output a table

The difference between the while and do while

Arrays in PHP

Declaring an array: array ()//[]

Use Principle: find the building value based on the name of the building

Defining an indexed array

$arr = [23,54, ' King ', true];

Print_r ($arr);//print Array

$arr = [

23=> ' a ',

54=> ' B ',

-12=> ' C ',

23=> ' d '

];

Print_r ($arr);

Duplicate name will produce overwrite

Iterate through the array method in Php:

foreach ($arr as $k = = $v) {

Echo $k, $v;

}

Basic PHP Learning

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.