Home > Backend Development > PHP Tutorial > Php interview questions_PHP tutorial

Php interview questions_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-14 10:12:03
Original
1284 people have browsed it

1. Calculate relative path


 function getpathinfo( $a, $b ) { 
    $a2array    = explode('/', $a); 
    $b2array    = explode('/', $b); 
    $pathinfo   = ''; 
    for( $i = 1; $i <= count($b2array)-2; $i++ ) { 
        $pathinfo.=$a2array[$i] == $b2array[$i] ? &#39;../&#39; : $b2array[$i].&#39;/&#39;; 
    } 
    print_R($pathinfo); 
} 
//计算出 c.php相对于e.php的相对路径应该是../../12/34  
$a          = &#39;/a/b/c/d/e.php&#39;; 
$b          = &#39;/a/b/12/34/c.php&#39;; 
getpathinfo($a, $b); 
?> 

function getpathinfo( $a, $b ) {
    $a2array    = explode(&#39;/&#39;, $a);
    $b2array    = explode(&#39;/&#39;, $b);
    $pathinfo   = &#39;&#39;;
    for( $i = 1; $i <= count($b2array)-2; $i++ ) {
        $pathinfo.=$a2array[$i] == $b2array[$i] ? &#39;../&#39; : $b2array[$i].&#39;/&#39;;
    }
    print_R($pathinfo);
}
//计算出 c.php相对于e.php的相对路径应该是../../12/34
$a          = &#39;/a/b/c/d/e.php&#39;;
$b          = &#39;/a/b/12/34/c.php&#39;;
getpathinfo($a, $b);
?>

Copy after login

2. Paging principle

 SELECT * FROM table &hellip;&hellip; limit   开始位置 , 操作条数  分页原理 
分页公式: 
(当前页数 - 1 )X 每页条数 , 每页条数 
Select * from table limit ($Page- 1) * $PageSize, $PageSize 

SELECT * FROM table &hellip;&hellip; limit   开始位置 , 操作条数  分页原理
分页公式:
(当前页数 - 1 )X 每页条数 , 每页条数
Select * from table limit ($Page- 1) * $PageSize, $PageSize

Copy after login


3. Determine whether it is post or get

 $_SERVER[&#39;REQUEST_METHOD&#39;] == &#39;POST&#39; 

$_SERVER[&#39;REQUEST_METHOD&#39;] == &#39;POST&#39;

Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477241.htmlTechArticle1. Calculate relative path function getpathinfo( $a, $b ) { $a2array = explode(/, $a ); $b2array = explode(/, $b); $pathinfo = ; for( $i = 1; $i = count($b2array)-2; $i++ ) { $pathinfo....
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template