1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. 比較基礎(chǔ)的php面試題及答案

        時(shí)間:2020-11-25 13:36:45 筆試題目 我要投稿

        比較基礎(chǔ)的php面試題及答案

          編程題:

        比較基礎(chǔ)的php面試題及答案

          1. 寫一個(gè)函數(shù),盡可能高效的,從一個(gè)標(biāo)準(zhǔn) url 里取出文件的擴(kuò)展名

          例如: http://www.sina.com.cn/abc/de/fg.php?id=1 需要取出 php 或 .php

          答案1:

          function getExt($url){

          $arr = parse_url($url);

          $file = basename($arr['path']);

          $ext = explode(“.”,$file);

          return $ext[1];

          }

          答案2:

          function getExt($url) {

          $url = basename($url);

          $pos1 = strpos($url,”.”);

          $pos2 = strpos($url,”?”);

          if(strstr($url,”?”)){

          return substr($url,$pos1 + 1,$pos2 – $pos1 – 1);

          } else {

          return substr($url,$pos1);

          }

          }

          2. 在 HTML 語言中,頁面頭部的 meta 標(biāo)記可以用來輸出文件的編碼格式,以下是一個(gè)標(biāo)準(zhǔn)的 meta 語句

          請使用 PHP 語言寫一個(gè)函數(shù),把一個(gè)標(biāo)準(zhǔn) HTML 頁面中的類似 meta 標(biāo)記中的 charset 部分值改為 big5

          請注意:

          1. 需要處理完整的 html 頁面,即不光此 meta 語句

          2. 忽略大小寫

          3. ‘ 和 ” 在此處是可以互換的'

          4. ‘Content-Type’ 兩側(cè)的引號是可以忽略的,但 ‘text/html; charset=gbk’ 兩側(cè)的不行

          5. 注意處理多余空格

          3. 寫一個(gè)函數(shù),算出兩個(gè)文件的相對路徑

          如 $a = ‘/a/b/c/d/e.php’;

          $b = ‘/a/b/12/34/c.php’;

          計(jì)算出 $b 相對于 $a 的相對路徑應(yīng)該是 ../../c/d將()添上

          答:function getRelativePath($a, $b) {

          $returnPath = array(dirname($b));

          $arrA = explode(‘/’, $a);

          $arrB = explode(‘/’, $returnPath[0]);

          for ($n = 1, $len = count($arrB); $n < $len; $n++) {

          if ($arrA[$n] != $arrB[$n]) {

          break;

          }

          }

          if ($len – $n > 0) {

          $returnPath = array_merge($returnPath, array_fill(1, $len – $n, ‘..’));

          }

          $returnPath = array_merge($returnPath, array_slice($arrA, $n));

          return implode(‘/’, $returnPath);

          }

          echo getRelativePath($a, $b);

        【比較基礎(chǔ)的php面試題及答案】相關(guān)文章:

        比較基礎(chǔ)的php面試題及答案-填空題01-02

        PHP面試題附答案01-01

        六道php面試題附答案01-02

        PHP筆試題及答案01-01

        Yahoo的PHP面試題01-01

        PHP面試題集01-03

        微軟面試題及答案09-07

        Adobe面試題及答案11-09

        Yahoo-PHP面試題01-01

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>