zoukankan      html  css  js  c++  java
  • php经典面试题

    1. 用PHP打印出前一天的时间,打印格式是2007年5月10日 22:21:21

    2. PHP代码如下:
    $a="hello"; 
    $b=&$a;
    unset($b);
    $b="world"; 
    echo $a;
    其结果是?
    3. PHP代码如下:
    $str="cd"; 
      $$str="landog";  
    $$str.="ok";
    echo $cd;
    其结果是? 
    4. 用PHP写一段代码,实现不使用第3个变量,交换$a、$b的值,$a、$b的初始值自己定。
    5. 根据题目要求,用PHP写出代码。
    表名User 
    ID  Name   Tel         Content   Date 
    1   张三 13333663366  大专毕业  2006-10-11
    3   张三 13612312331  本科毕业  2006-10-15
    5   张四 020-5566556  中专毕业  2006-10-15
    4   王五 13521212125  大专毕业   2006-12-25
    2   …………
    6   …………
    假设数据库连接如下:
    $mysql_db=mysql_connect("local","root","pass");
    @mysql_select_db("DB",$mysql_db);
    (1)查询出所有Name等于“张三”的记录,并输出。
    (2)按ID升序查询,只返回排序后的前3条记录,并输出。
    6. javascript能否定义二维数组,如果不能你如何解决?
    7. 假设a.html和b.html在同一个文件夹下面,用javascript实现当打开a.html五秒钟后,自动跳转到b.html。
    8. 有两个文件a.html和a.php,代码如下:
    a.html

    <html>
    <head>
      <meta http-equiv=Content-Type content=text/html;charset=utf-8>
      <title>PHP程序员面试</title>
    </head>
    <body>
      <center> 
       <form method="post" action="a.php">
        <table border="1"> 
         <tr>
          <td align="right">姓名:</td>
          <td align="left"><input type="text" ></td> 
         </tr>  
         <tr>
          <td align="right">电话:</td>
          <td align="left"><input type="text" ></td>  
         </tr> 
         <tr>
          <td align="right">邮箱:</td>
          <td align="left"><input type="text" ></td> 
         </tr> 
         <tr>
          <td align="right">地址:</td>
          <td align="left"><input type="text" ></td>  
         </tr> 
         <tr>
          <td align="center" colspan="2">
           <input type="submit" value="提交"> 
           <input type="reset" value="重填">
          </td>  
         </tr>
        </table>
       </form>
      </center>
    </body>
    </html>


    a. php

    <?php
         $user_name = $_GET['user_name'];
         $user_tel = $_GET['user_tel'];
         $user_email = $_GET['user_email'];
         $user_add = $_GET['user_add'];
         echo "用户名:$user_name<br>电话:$user_tel<br>邮箱:$user_email<br>地址:$user_add<br>";
    ?>


    (1)请画出a.html在浏览器的显示效果图。
    (2)在a.html中输入:用户名=张三,电话=020-38259977,邮箱=sunrising@srtek.cn,地址=广州升瑞,按提交按钮后输出结果是?
    9. 你是否使用过版本控制工具,如果有,请简要说明。
    10. 利用CSS样式表定义已访问的超链接字体大小为14pt,颜色为red。
    11. 移动任意一位数或符号,使等式成立, 102 = 101-1。注:是移动不是交换,等号不能分开。
    12. 规律题,3、1、4、1、5、9、2、(  ), 请按照规律在括号内写出下一表达式。
    13. 规律题,5、8、-3、5、-2、3、-1、(  ),请按照规律在括号内写出下一表达式。

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    答案:

    1. echo date('Y-m-d H:i:s', strtotime('-1 day'));

    2. hello

    3. landogok

    4.  $a = "abcd";
    $b = "1234";
    echo "初始化时 a=$a,b=$b<br>";
    $a = $a . $b;
    $b = strlen( $b );
    $b = substr( $a, 0, (strlen($a) - $b ) );
    $a = substr( $a, strlen($b) );
    echo "交换后 a=$a,b=$b<br>"; 

    5. (1)$sql = “select *  from User where >  $result = mysql_query( $sql );
      while( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ){
       echo $row[‘Name’];
      }
    (2) $sql = “select * from User order by ID asc limit 0,3”;
      $result = mysql_query( $sql );
      while( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ){
       echo $row[‘Name’];
      }
    6. javascript不支持二维数组定义,可以用arr[0] = new array()来解决

    7. javascript代码如下:
    <script>
    function go2b(){
      window.location = "b.html";
      window.close();

    setTimeout( "go2b()",5000 ); //5秒钟后自动执行go2b()
    </script>

    8. 

    (1)如下所示:

          略。因为懒得插入图片,如果想看结果可以把代码保存为html文件,再用浏览器打开查看。

    (2)输出结果应为:

          姓名:

          电话:

          邮箱:

          地址:

    因为表单是用post方式提交,但在a.php中却用get方式来读取,所以不会读到任何值。 

    9. 略 

    10.   a:visited { font-size: 14pt; color: red; }

    11.  102 = 101-1  

    12. 答案为6,因为∏=3.1415926

    13. 答案为2,规律为n=(n-2) – |(n-1)| ,n>=3

     

  • 相关阅读:
    【 DCOS 】织云 CMDB 管理引擎技术详解
    腾讯云无服务器云函数架构精解
    深度学习在 CTR 中应用
    一文教你迅速解决分布式事务 XA 一致性问题
    小程序开发工具全新上线
    秦俊:开放 DevOps 敏捷开发套件,助力开发者驰骋云端
    张兴华:云端架构助力企业快速成长
    王磊:AI 时代物流行业的 OCR 应用
    陈杰:无服务器架构,让云端开发更纯粹
    腾讯织云:DevOps 流水线应用平台践行之路
  • 原文地址:https://www.cnblogs.com/smartyman/p/3797119.html
Copyright © 2011-2022 走看看