Friday 9 November 2018

wordpress - What does "->" mean/refer to in PHP?





What does -> mean/refer to in PHP?



In the following from WordPress, I know what the if statement does, for example, but what does the -> do?



max_num_pages > 1 ) : ?>   

Answer



-> accesses a member of an object. So $wp_query->max_num_pages is accessing the field max_num_pages in the object $wp_query. It can be used to access either a method or a field belonging to an object, and if you're familiar with C++ or Java, it's equivalent to myObject.myField


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...