Cách kiểm tra một địa chỉ IP có tồn tại hay không
Trang 1Cách kiểm tra một địa chỉ có tồn tại hay không
view plainprint?
1 <?php
2
3 $test = @fopen("http://download.yahoo.com/dl/msgr75/us/yamsgr75us.exe", "rb");
4
5 if ( $test )
6 {
7 print "File ok";
8 }
9 else
10 {
11 print "File not found";
12 }
13
14 ?>
<?php $test = @fopen("http://download.yahoo.com/dl/msgr75/us/yamsgr75us.exe", "rb"); if ( $test ) { print "File ok"; } else { print "File not found"; } ?>
Dòng bôi đen là 1 địa chỉ để download YM, bạn chỉ việc thay vào đó địa chỉ của file nhạc
Đôi khi nó rất đơn giản nhưng lại rất ít được biết đến :) Hy vọng nó sẽ giúp cho bác nào viết site nhạc
Example code:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<b>Nhập link bạn cần kiểm tra vào đây</b>
<form method="post" action="" target="_self">
<input type="text" name="link" value="http://" size=50 maxlength=200>
<br>
<input type="submit" value="Check" name="checklink">
</form>
view plainprint?
1 <?php
2 if (isset($_POST["link"])) $link = $_POST["link"]; else $link='';
3 $test = @fopen("$link", "rb");
4
5 if ( $test )
6 {
7 print "File is ok";
8 }
9 else
10 {
11 print "File not found";
12 }
13
14 ?>
Trang 2<?php if (isset($_POST["link"])) $link = $_POST["link"]; else $link=''; $test = @fopen("$link", "rb");
if ( $test ) { print "File is ok"; } else { print "File not found"; } ?>