Some basic grammars related to php calculations

1. Basic knowledge
(1) Define a variable: For example: Define a variable: For example:Given sense a th variable amount : as : a = [], an array named a defined.
$this-> indicates that the properties or methods of this class are used inside the class itself.
(2):: Call
this −> means to use the properties or methods of this class within the class itself. Class name:: this-> indicates that the properties or methods of this class are used inside the class itself. Class name:this>Table shows the type present themselves within a section that the use of this type of metal properties or are square method . Class name : : variable or method name
EG:
the Test ::test to get the test to getT E S T to get obtain test known attribute values of
Test :: test (); directly call the static method test
(. 3) & references - call variables / functions / object
a variable.: REFERENCE allows you to use the PHP two variables to point to the same content
EG:Katex the parse error: the Expected 'the EOF', GOT '&' position AT. 4: B = & a;
B, and a pointer to a variable the same time, when a variant, also a further variation.
b. Function: function call by address, function reference return
function call by address
eg:
function f1(&a) method body f 1 (a) {method body} f1(A ) square method body F . 1 ( b)
function call F1 (b) transmitting b) transferb ) transfer delivery contents of the variable b, in which the memory address, by the functionvalue of a can change can change the value of aa The value will be to change the variable value of b
* PHP predetermined byKaTeX parse error: Expected 'EOF'mode obtained is ...a variable memory address points In the same place
eg:
Object:
Second, calculation related grammar
(1) Addition, subtraction, multiplication and division
(1) Addition (not used temporarily, will be used later)
(2) Subtraction: bcsub()
a. Function: Used forsubtractionSubtract an arbitrary-precision number from the other. This function accepts two arbitrary-precision numbers as strings, and returns the subtraction of two numbers after scaling the result to the specified precision
. b. Syntax: bcsub(numstr 1, num_str1,n u mstr1num_str2, s c a l e V a l ) b c s u b ( scaleVal) bcsub( s c a l e V a l ) b c s u b ( left operand,right operand, right operand,The right operation for the number , reservation number of decimal places)
num_str1, num_str2 this parameter is a string type, representation (the right) or the left operand we want to perform subtraction of two numbers. This parameter is required.
scaleVal: This parameter is of type int and is optional. This parameter represents the number of digits after the decimal point in the addition result. Its default value is zero.
(3) Multiply (not used yet, use complement later)
(4) Divide: bcdiv () 2 arbitrary precision number division calculation
syntax: bcdiv (string $left_operand, string $right_operand [, int $scale = int] )
left_operand left operand, string type
right_operand right operand, string type
scale: retain the number of decimal places
(two) data result processing
(1) floor() rounded down to the nearest integer
floor(x) : Round off the fractional part of x.
(2) round() rounds floating-point numbers.
Format: round(x,prec)
x: Optional. Specifies the number to be rounded.
prec: optional. Specify the number of digits after the decimal point. The default is 0.
(3) Min() takes the smallest value
$a = min($b), which is the smallest value in a=b.
3. Data format conversion
(1) JSON mutual conversion
json_encode()It means to convert the data format of objects and arrays to data in json format;
json_decode() converts data in json format to objects, arrays, and to convert to arrays, add true
json = ′ "a": 1, "b": 2 , "c": 3, "d": 4, "e": 5 ′; jsondecode (json ='{"a":1,"b":2,"c":3,"d":4, "e":5}'; json_decode(json="a":1,"b":2,"c":3,"d":4,"e":5;jsonde c o d e ( json); //
 Convertto objectjson_decode($json,true); //Convert to array
Fourth, other syntax
(1) isset() detects whether the variable is set
a. Basic format: isset (mixed var [, mixed var [, …]])
b. Return true: the variable exists and the value is not NULL
. When multiple variables are checked, each single item meets the previous requirement before returning TRUE, otherwise the result is FALSE;
c. Return false : The variable does not exist, exists and its value is NULL.

Guess you like

Origin blog.csdn.net/qq_44801116/article/details/105877166