Explanation of the Arrow (-& gt;) in the PHP script language and the strpos () function
First, paste two pieces of code:
Code 1
$sql = 'SELECT c.customers_email_address,o.customers_state,o.customers_name,o.date_purchased,op.products_quantity FROM '.TABLE_ORDERS_PRODUCTS.' op, '.TABLE_ORDERS.' o,'.TABLE_CUSTOMERS.' cWHERE op.orders_id = o.orders_idand c.customers_id = o.customers_id AND `products_id` ='.intval($_GET['products_id']).'GROUP BY o.customers_idORDER BY o.orders_id DESC';$Indexproducts = $db->Execute ( $sql);
Code 2:
fields['customers_email_address']; $stremail=str_replace($stremail{strpos($stremail,"@")-2}.$stremail{strpos($stremail,"@")-1}."@","**@",$stremail); echo $stremail; ?>
In code 1, a database statement is mainly assigned to the $ SQL variable, and then runs the database statement through Execute ($ SQL). The Arrow (->) it can be regarded as a pointer or reference to obtain the value of the database result after execution, put it in $ db, and assign the value to $ Indexproducts.
In this database statement, there is a function intval (), which is a type conversion function, which is no big difference from int,
For intval (), if the parameter is a string, the integer represented by the first numeric string that is not a digit before the string is returned. If the first string is '-', it starts from the second string.
If the parameter is a number of characters, return the value after the value is rounded up.
Of course, the value returned by intval () is within the range (-2147483648 ~ 2147483647). The value that exceeds this range will be replaced by the boundary value.
Here is used to obtain the product ID and convert the format.
Code 2:
Here we will focus on two functions. The first one can be understood without much talk. str_replace () is a character replacement function;
The strpos () function is used to return the position where the string first appears in another string.
Syntax: (parameter 3 is an optional parameter)
strpos(string,find,start)
The code in this section indicates that the number * is used to replace the two characters before the @ character in the mailbox.
Note: This function is case sensitive. if it is case insensitive, refer to the stripos () function.
Appendix: Write about it. You are welcome to shoot bricks!