In reply to adrian,
________số 8
function resolve_url[$base, $url] {
if [!strlen[$base]] return $url;
// Step 2
if [!strlen[$url]] return $base;
// Step 3
if [preg_match['!^[a-z]+:!i', $url]] return $url;
$base = parse_url[$base];
if [$url{0} == "#"] {
// Step 2 [fragment]
$base['fragment'] = substr[$url, 1];
return unparse_url[$base];
}
unset[$base['fragment']];
unset[$base['query']];
if [substr[$url, 0, 2] == "//"] {
// Step 4
return unparse_url[array[
'scheme'=>$base['scheme'],
'path'=>substr[$url,2],
]];
} else if [$url{0} == "/"] {
// Step 5
$base['path'] = $url;
} else {
// Step 6
$path = explode['/', $base['path']];
$url_path = explode['/', $url];
// Step 6a: drop file from base
array_pop[$path];
// Step 6b, 6c, 6e: append url while removing "." and ".." from
// the directory portion
$end = array_pop[$url_path];
foreach [$url_path as $segment] {
if [$segment == '.'] {
// skip
} else if [$segment == '..' && $path && $path[sizeof[$path]-1] != '..'] {
array_pop[$path];
} else {
$path[] = $segment;
}
}
// Step 6d, 6f: remove "." and ".." from file portion
if [$end == '.'] {
$path[] = '';
} else if [$end == '..' && $path && $path[sizeof[$path]-1] != '..'] {
$path[sizeof[$path]-1] = '';
} else {
$path[] = $end;
}
// Step 6h
$base['path'] = join['/', $path];
My Twitter
Nếu cần phải có liên kết bên trong PHP, thì bạn có hai tùy chọn. Một tùy chọn là kết thúc PHP, nhập liên kết bằng HTML, sau đó mở lại PHP. Đây là một ví dụ
My Twitter
Tùy chọn khác là in hoặc lặp lại mã HTML bên trong PHP. Đây là một ví dụ
Một việc khác mà bạn có thể làm là tạo một đường liên kết từ một biến. Giả sử rằng biến $url chứa URL của một trang web mà ai đó đã gửi hoặc bạn đã lấy từ cơ sở dữ liệu. Bạn có thể sử dụng biến trong HTML của mình
My Twitter
Dành cho người mới bắt đầu lập trình PHP
If you are new to PHP, remember you begin and end a section of PHP code using respectively. This code lets the server know that what is included is PHP code. Try a PHP beginner's tutorial to get your feet wet in the programming language. Before long, you'll be using PHP to set up a member login, redirect a visitor to another page, add a survey to your website, create a calendar, and add other interactive features to your webpages.
Trích dẫn bài viết này
Định dạng
mla apa chicagotrích dẫn của bạn
Bradley, Angela. "Cách tạo liên kết trong PHP. "ThinkCo. https. //www. suy nghĩ. com/create-links-in-php-2693950 [truy cập ngày 26 tháng 12 năm 2022]