search

1.  写出下列代码的结果:
                $a="Hello World!";
            $b=$a;
            print("\$b=$b
");
            print('$a=$a
');
   ?>

$b=Hello World!
$a=$a
      //'\'是逃逸符,屏蔽紧跟在后面的单个特殊字符的特殊用法
                                                          //''单引号对,屏蔽包含在内的几乎所有的特殊字符的特殊含义,除了本身
                                                          //另外,在命令行下调试这些代码,
是不会作为换行输出的~ 如果在browser,另当别论

2.  写出下列代码输出结果:
                $a="First";
            $b=&$a;
            $c=$a;
            $a="Second";
            print("$a,$b,$c
");
   ?>

Second,Second,First
              //$b是$a的引用赋值,所以$a的变化就是$b的变化
                                                      //$c可以看作$a复制一次以后的副本,所以是不相干的两个变量,因此,$a的改变不影响$c
   
3.  写出下列代码输出结果:
                 $a=2;
             $b="1.2SBC3";
             $c="EFG";
             $result1=$a.$b;
             $result2=$a*$b;
             $result3=$a*$c;
             print("$result1,$result2,$result3
");
    ?>

21.2SBC3,2.4,0
               //$result1是字符串的连接,btw,如果这题是2.$b,那系统会报error
                                                //$result2是数字的乘法,php中会自动舍弃第一个不是数字的字符开始后面的字符
                                                 //$result3是数字的乘法,与2不同的是,$c中没有任何数字型字符,因此整体被强行转换为数值型,也就是0,然后再和$a=2相乘,最后结果就是0

4.  下列不正确的变量名是:
    A. $_test    B. $2abc    C. $Var    D. $%Var

b

5.  语句for($k=0;$k=1;$k++);和语句for($k=0;$k==1;$k++);执行的次数分别是:
    A. 无限和0   B. 0和无限   C.都是无限   D. 都是0

A

/**
* 这里要重点讲一下这题,这里选择A应该是没问题,人所皆知
* 问题在于,如果第一句话改一下,变成for($k=0;$k=0;$k++);,那么循环体会被执行的次数呢?
*
* 答案是0
*
* 原因是for(expr A; expr B; expr C)在判断是否要执行循环体时,我们关心的是表达式expr B的真值。
* 注意!$k=0这个表达式的值是0!而不是可能的复制成功返回的1!
* 所以,for循环的循环判断条件为永假,自然就不会执行循环体了~~~
*
* :)
**/


6.  php函数不支持的功能有:
    A. 可变的函数名称    B. 可变的参数个数   C. 通过引用传递参数
    D. 通过指针传递参数   E. 实现递归函数

d

7.  下列对php中类的描述,不正确的是:
    A. 支持单一继承  B. 支持多继承  C. 不支持构造函数  D.不支持析构函数   
    E.必须使用$this指针来引用成员变量

b 多继承好像是要用到接口

8.  找出下列代码中的错误并修正:
                 $a[0]=""Ryan;
             $b["value"]=785.9;
             $c["blue"][0]="Ada";
             print("$a[0],$b["value"],$c["blue"][0]
");
     ?>

                 $a[0]="Ryan";
             $b["value"]=785.9;
             $c["blue"][0]="Ada";
             print("$a[0]"."$b[value]"."{$c[blue][0]}"."
");
     ?>

//引号没什么好说的
//还有关键是最后一行的$c[blue][0],如果不用花括号括起来,那么系统会自动先变量替换$c[blue],问题是这个值不存在,所以,替换完毕后的xxxx[0]也就没有了,所以会报错。这就是所谓的变量数组


9.  请按照由高到低的顺序写出下列操作符的优先级:
      and,=,>,+,~

~ + > = and 我猜的

10. 试述isset()和empty()的区别


isset()
测试变量是否存在

empty()
测试变量是否为空

在php这样的对变量定义不严格的语言中
如果一个变量从没有声明过,那么isset==false|empty==true
如果一个变量已声明,但赋值为NULL,那么和前一种情况一样
如果一个变量已声明,但赋值为'',那么isset==true|empty==true
如果一个变量已声明,且正常赋值,那么isset==true|empty==false

example as follow:

$b = NULL;
$c = '';
$d = 'str';
echo isset($a)."a\n";
echo empty($a)."b\n";
echo isset($b)."c\n";
echo empty($b)."d\n";
echo isset($c)."e\n";
echo empty($c)."f\n";
echo isset($d)."g\n";
echo empty($d)."h\n";
?>

11. 请用尽可能少的语句实现对输入Email地址进行验证的功能.

eregi('^[_a-z0-9]+(\.[_a-z0-9-]+)*@[a-z0-9]+(\.[a-z0-9-]+)*$',$emailaddress)

12. 写一算法,将下列数组按升序排序,并写出排序算法名称:
     $arrVar=array(64,29,1,43,30,9,39,75,4,11)

冒泡排序,过程略

13. 写一段程序,将文本文件中的每一个单词的首写字母转换成大写,并保存回原文件.
      提示:将串中的单词首字母转换成大写的函数:  string ucwords(string str)



14. 请写出php访问MYSQL数据库的几种方式,并做简要介绍.

15. 请写出PHPSession的实现方法;介绍你认为最好的实现方法,并说明理由.
      提示:SessionID的传递方式,Session变量的存储方法等.

16. PHP程序会有什么漏洞?

我就是最大的漏洞……


不知道对不对~~ 呵呵~~ 发现概念性的东西还是挺纠缠不清的~~
字多的慢慢再写~~~:)

Statement
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
PHP in Action: Real-World Examples and ApplicationsPHP in Action: Real-World Examples and ApplicationsApr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP: Creating Interactive Web Content with EasePHP: Creating Interactive Web Content with EaseApr 14, 2025 am 12:15 AM

PHP makes it easy to create interactive web content. 1) Dynamically generate content by embedding HTML and display it in real time based on user input or database data. 2) Process form submission and generate dynamic output to ensure that htmlspecialchars is used to prevent XSS. 3) Use MySQL to create a user registration system, and use password_hash and preprocessing statements to enhance security. Mastering these techniques will improve the efficiency of web development.

PHP and Python: Comparing Two Popular Programming LanguagesPHP and Python: Comparing Two Popular Programming LanguagesApr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

The Enduring Relevance of PHP: Is It Still Alive?The Enduring Relevance of PHP: Is It Still Alive?Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP's Current Status: A Look at Web Development TrendsPHP's Current Status: A Look at Web Development TrendsApr 13, 2025 am 12:20 AM

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP vs. Other Languages: A ComparisonPHP vs. Other Languages: A ComparisonApr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP vs. Python: Core Features and FunctionalityPHP vs. Python: Core Features and FunctionalityApr 13, 2025 am 12:16 AM

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP: A Key Language for Web DevelopmentPHP: A Key Language for Web DevelopmentApr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools