Explanation of the Arrow (->) in the PHP script language and the strpos () function

Source: Internet
Author: User
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!

 

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.