SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Syntax Question

    In this line of code:

    PHP Code:
    if($comment->comment_author_email == get_the_author_email()) {
       
    $isByAuthor true;

    1. what does the -> after $comment do/mean?

    2. is this comparing to the result of the get_the_author_email function then?

    also, does if($isByAuthor) {echo....} simply check this as boolean true/false and echo only it if $isByAuthor is true?

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    5 Thread(s)
    1.) accesses public property of the object
    2.) No, its comparing the return value of the get_the_author_email function

    Quote Originally Posted by berliner_kindl
    also, does if($isByAuthor) {echo....} simply check this as boolean true/false and echo only it if $isByAuthor is true?
    Not exactly as it is not a strict comparison. if you would like to check whether it is a true or false boolean value the below code would be more appropriate.

    PHP Code:
    if($isByAuthor===true) {
      echo 
    'by author';


  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. okay this line of code:

    PHP Code:
    if($comment->comment_author_email == get_the_author_email()) 
    is comparing the return value or the comment_author_email method (function) found in the $comment object, correct?

    2. isn't a return value and a result the same thing, just semantics?

    3. okay, so what does if($isByAuthor) do?

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    5 Thread(s)
    3.) It would be a loose comparison. For example, a empty string loosely evaluates to false and the same with 0.

    http://www.phpbuilder.com/manual/en/...omparisons.php

    2.) No, its referred to as a return value.

    Quote Originally Posted by berliner_kindl
    is comparing the return value or the comment_author_email method (function) found in the $comment object, correct?
    is comparing the return value or the comment_author_email function. A method is different from a function.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •