Fungsi untuk Menampilkan URL ini

  • Berikut ini ialah Fungsi untuk Menampilkan URL ini, dimana script ini berfungsi untuk menampilkan URL yang tertera di urlbar peramban pada sebuah webpage atau domain.

    <?php
    function menampilkan() {
    $urlini = 'http';
    if ($_SERVER["HTTPS"] == "on") {$urlini .= "s";}
    $urlini .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
    $urlini .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
    $urlini .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $urlini;
    }
    echo menampilkan();
    ?>
    


    Output http://antonsulistiyono.com/belajar-php/fungsi-untuk-menampilkan-url-ini.html.
    Bisa juga digunakan untuk mengganti fungsi

    <?php the_permalink() ?>

    Sumber: http://www.webcheatsheet.com/PHP/get_current_page_url.php, lihat juga Struktur Penulisan php.

    No related posts.

    Back to top ↑

11 Responsesto “Fungsi untuk Menampilkan URL ini”

Comment page 1 of 1

Subscribe to this discussion via RSS

"write as if you were talking to a good friend (in front of your mother)."

.haveyoursay

Disclaimer: For any content that you post, you hereby grant to Anton the royalty-free, irrevocable, perpetual, exclusive and fully sublicensable license to use, reproduce, modify, adapt, publish, translate, create derivative works from, distribute, perform and display such content in whole or in part, world-wide and to incorporate it in other works, in any form, media or technology now known or later developed. Some rights reserved.