Php面试题_PHP教程

WBOY
Libérer: 2016-07-14 10:12:03
original
1184 Les gens l'ont consulté

1、计算相对路径


 

 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);
?>

Copier après la connexion

2、分页原理

 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

Copier après la connexion


3、判断是post还是get

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

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

Copier après la connexion

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477241.htmlTechArticle1、计算相对路径 function getpathinfo( $a, $b ) { $a2array = explode(/, $a); $b2array = explode(/, $b); $pathinfo = ; for( $i = 1; $i = count($b2array)-2; $i++ ) { $pathinfo....
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!