Php string learning Notes

You can use strstr () and strrchr () functions to find characters in php strings. The structure of the two functions is as follows:Strstr ($ haystack, $ needle)Strrchr ($ haystack, $ needle)// $ Haystack indicates the parent string, and $ needle

Php if else swicth condition control statement learning Notes

In php, the basic process control structures include sequence structure, branch structure, and cyclic structure.Common control statements include:If, if... Else judgment statementSwitch branch statementWhile, do... While loop statementFor loop

Introduction to functions for determining null strings in php

String; judge whether the string is null; output judgment; you can modify it The code is as follows:Copy code If (empty ($ C_char) return false; // whether it is setIf ($ C_char = '') return false; // whether it is null Use = ""Example The

Php determines whether a variable constant exists

The defined () function checks whether a constant exists.If a constant exists, true is returned; otherwise, false is returned. The code is as follows:Copy code If (defined ('myconstant ')){Echo "constant MYCONSTANT exists ";} Else {Echo

Php foreach/for loop bounce

The code is as follows:Copy code  // The Current php loop is 1, and the loop increases sequentially from the inside to the outside. The default break is 1, for example, jumping out of the 2nd-layer loopFor ($ I = 0; $ I Foreach (array (1, 2, 3)

Php to find the array value program

There are three methods to check whether an element is in an array:The in_array 'function searches for the given value in the array. In_array (value, array, type) type is optional. If this parameter is set to true, check whether the data to be

PHP 24-hour timing method Time Implementation Program

The code is as follows:Copy code Function getTime (){$ Time = "";// Morning time$ H1 = date ("h")> 12? (Date ("h")-12): date ("h ");// Afternoon time$ H2 = (date ("h") + 12)> = 24 )? Date ("h") :( date ("h") + 12 );// Determine whether it is

PHP check box selected and written to database

Form.html The code is as follows:Copy code 3 7 1 15 Then create a program to process the form:Checkbox. php The code is as follows:Copy code $ A = $ _ POST ["s"];Print_r ($ );?> However, the above program is only used to show whether

Php uses json instead of serialize

Note that when json_decode is returned, the object is required.Json_decode ("string", ture); later I found it was not so perfect ..Json_encode will encode Chinese characters. If a large number of Chinese characters are contained, the length exceeds

Php randomly extracts some element code from the array

The code is as follows:Copy code  Class getValues {Public function inputValue ($ inputArray ){$ This-> inputArray = $ inputArray;    }Public function getValue ($ number ){$ This-> number = $ number;For ($ I = 0; $ I number; $ I ++ ){$ Index =

Php variable range, reference, object reference, transfer

Variable rangeThe scope of a variable is the context defined by it (that is, its effective range ). Most PHP variables have only one separate range. This separate range span also contains the files introduced by include and require. For example:

Php bit operation usage

$ A & $ B and (bitwise and)$ A | $ B or (by bit or)$ A ^ $ B Xor (bitwise Xor)~ $ A Not (Not by bit)$ A $ A >>$ B Shift right (right Shift)Details$ A & $ B: Set the bitwise of 1 in both $ a and $ B to 1;Example: 10 & 12 = 810 101012 11001000 8$ A | $

Differences between global and $ GLOBALS [] in php

According to the official explanation:1. $ GLOBALS ['var'] is an external global variable. The code is as follows:Copy code $ Var1 = 1;Function test (){Unset ($ GLOBALS ['var1']);}  Test ();Echo $ var1;?> 2. global $ var is an external

Php prompts undefined index solution

When $ _ post [''] and $ _ get [''] are used to obtain parameters in the form, the following error occurs: Notice: Undefined index :--------;Server configuration modificationModify the php. ini configuration file, The code is as follows:Copy code

Differences between php foreach and for statements

 // Foreach$ Tar = array (1 => 'East ',2 => 'West ',3 => 'south ',4 => 'North ',5 => 'Southeast ',6 => 'southwest ',7 => 'Northeast region ',8 => 'Northwest ',9 => 'North and South ',10 => 'thes ',); The code is as follows:Copy code $ TM = 'West

Introduction to PHP functions

Custom functionsA function is a set of independent program statements to implement a function. After writing a function into a function, you can easily use it as needed. Reasonable use of functions can make our PHP programs more concise and easy to

Function usage in php

User-defined functions are also called Udfs. They are not provided by PHP and are created by programmers. because you have created such functions, you can fully control these functions. therefore, a function can be run in the desired way.1. Declare

Common php array operation functions

Array_values () // returns all elements in the arrayArray_walk () // use a custom function to traverse an array.Arsort (); // reserve the relationship between the values of the array subscript for inverted sortingAsort () // reserve the relationship

Php batch set IIS Directory instance code

The code is as follows:Copy code // Obtain the file directory list. This method returns an array.Function getDir ($ dir = ''){$ Dir = empty ($ dir )? Getcwd (): $ dir;$ DirArray [] = NULL;If (false! = ($ Handle = opendir ($ dir ))){$ I = 0;While (

Total Pages: 12780 1 .... 8791 8792 8793 8794 8795 .... 12780 Go to: GO

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.