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 Years
Discussion Span
Last Post by almostbob

<= 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



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..

$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";


## 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.