Thủ thuật php

Đăng bởi admin lúc June 4th, 2009 - trong chuyên mục Lập trình

Sử dụng PHP để chuyển đến 1 URL khác

PHP

Code:

<?php

header(“Location: http://yoursite.com/”)

?>

Trong HTML bạn có thể sử dụng đoạn mã sau:

Code:

<html>

<head>

<title>Please wait…</title>

<script language=”JavaScript”>

self.location.href=’http://yoursite.com/’;

</script>

</head>

<body>

</body>

</html>

Bạn sử dụng đoạn PHP sau trong đoạn mà bạn muốn hiển thị:

PHP

Code:

<?

$browser = “$HTTP_USER_AGENT”;

print(“Bạn đang sử dụng: $browser”)

?>


hoặc

PHP

Code:

print(“<font color=”red”> Bạn đang sử dụng: $browser <font>”)

Còn cập nhật thêm

Tags:

2 Responses

  1. Công Lý says:

    Trong bài anh viết có 1 chỗ sai là chỗ này:
    print(“ Bạn đang sử dụng: $browser ”)

    Chính xác là:
    print(“ Bạn đang sử dụng: $browser ”)

  2. admin says:

    ủa zì mà sửa lại y xì vậy ^^
    PHP4 và PHP5 chạy bình thường đấy PHP3 thì kô chạy thui ^^

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© Mr.Cam update from iFeature(Cyberchimps)