0

Hello everyone, I'm newbie and I need some helpful for my problem:

class pages {
    var $total_pages = NULL;
    var $scroll_pages = NULL;
    ...
    function page_link (...) {
        if ($this -> total_pages <= $this -> scroll_pages)  {
        ...
        }
    }
}

Sorry I don't understand the code above and It's very long, so I don't write full code. But my problem is focus on this line:

if ($this -> total_pages <= $this -> scroll_pages)  {

I don't understand the meaning of this line, can everybody help me ???
Thank in advandce to everybody.

6
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by almostbob
0

<= in this case means less than or equal to or in your example:

if the value of attribute $this->total_pages is less than or equal to a value of attribute $this->scroll_pages, then ...

See http://php.net/manual/en/language.operators.comparison.php

Attributes are variables of classes/objects, similar to properties in some other OOP languages. The -> is OOP operator to access properties and methods of an object (similar to a . in other OOP languages).

Edited by broj1: More clarification added

0

@nguoixanh,

Don't be confused with it. It is just a comparison operator. What the thing meant is that IF total_pages is LESS THAN or EQUAL to scroll_pages, THEN do something.

What you should have paid attention closely, is on how the script come up with this..
$this->$total_pages and $this -> scroll_pages, because that's the one that will prime yourself in OOP.

Something like this..
$this -> scroll_pages = $scroll_pages;
$this -> total_pages = $total_pages;


Without using the class pages, you can also practice using those operators by just practicing in something simple like..

<?php
$scroll_pages = 5;
$total_pages = 10;

## let's practice something similar to the page class above.
## normally in class you would start as $whatever = new page(); $whatever->page_link();, and the function page_link will get executed or evaluated..

if($total_pages <= $scroll_pages){

echo "Total pages is less than or equal to Scroll pages";
}

else{

## if you run this script, it should print Total pages is greater than Scroll pages on your screen

echo "Total pages is greater than Scroll pages";

}
?>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.