1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to fix Optional parameter declared before required parameter?

Discussion in 'PHP' started by Divvy, Nov 16, 2023.

  1. #1
    Can someone help me fix these errors, please?

    Code line:
    function pagination($per_page = 5, $page = 1, $url = '', $total)
    Code (markup):
    I tried this, but it breaks my site layout:
    function pagination($total, $per_page = 5, $page = 1, $url = '')
    Code (markup):
    Full code: https://paste2.org/Z3gZN4Ev

    I also found this code in my single.php:

    echo pagination($limit,$page,$m_Cpageurl.'?mrpage=',$rows);
    Code (markup):
    single.php full code: https://paste2.org/mMPeW8gZ

    Thank you in advance :)
     
    Last edited: Nov 16, 2023
    Divvy, Nov 16, 2023 IP
  2. PHPSecure

    PHPSecure Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    hey, is this still relevant?
     
    PHPSecure, Nov 17, 2023 IP
  3. Dotonomic

    Dotonomic Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    If you have PHP 8, you can call the function like this:
    pagination(total: $kckhg)
     
    Dotonomic, Dec 3, 2023 IP
  4. Dotonomic

    Dotonomic Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    I guess you'll want something like pagination(url: $u, total: $t);
     
    Dotonomic, Dec 3, 2023 IP