search

1. 如何用php的环境变量得到一个网页地址的内容?ip地址又要怎样得到?
 

 

echo $_SERVER['PHP_SELF'];
echo $_SERVER['REMOTE_ADDR'];
?>

 




2. 求两个日期的差数,例如2007-2-5 ~ 2007-3-6 的日期差数

$begin=strtotime('2007-2-5);
$end=strtotime('2007-3-6);
echo ($end-$begin)/24*60*60;
?>

 




3. 请写一个函数,实现以下功能:
字符串“open_door” 转换成 “OpenDoor”、”make_by_id” 转换成 ”MakeById”。

function changeStyle($str) {

$arrStr=explode('_',$str);
foreach($arrStr as $key=>$value){
$arrStr[$key]=strtoupper(substr($value,0,1)).substr($value,1);
// $arrStr[$key]=Ucfirst($arrStr[$value]);
}
return implode('',$arrStr);
}
$str1 = "open_door";
$str2 = "make_by_id";
echo changeStyle ( $str1 );
echo changeStyle ( $str2 );


4. 要求写一段程序,实现以下数组$arr1转换成数组$arr2:

$arr1 = array (
'0' => array ('fid' => 1, 'tid' => 1, 'name' =>'Name1' ),
'1' => array ('fid' => 1, 'tid' => 2 , 'name' =>'Name2' ),
'2' => array ('fid' => 1, 'tid' => 5 , 'name' =>'Name3' ),
'3' => array ('fid' => 1, 'tid' => 7 , 'name' =>'Name4' ),
'4' => array ('fid' => 3, 'tid' => 9, 'name' =>'Name5' ) 
);
$arr2 = array ( 
'0' => array ( 
'0' => array ( 'tid' => 1, 'name' => 'Name1'),
'1' => array ( 'tid' => 2, 'name' => 'Name2'),
'2' => array ( 'tid' => 5, 'name' => 'Name3'),
'3' => array ( 'tid' => 7, 'name' => 'Name4')
),
'1' => array ( 
'0' => array ( 'tid' => 9, 'name' => 'Name5' ) // 内容来自技术世界www.js4j.com 技术爱好者// 
)
);
$arr1 = array (
'0' => array ('fid' => 1, 'tid' => 1, 'name' =>'Name1' ),
'1' => array ('fid' => 1, 'tid' => 2 , 'name' =>'Name2' ),
'2' => array ('fid' => 1, 'tid' => 5 , 'name' =>'Name3' ),
'3' => array ('fid' => 1, 'tid' => 7 , 'name' =>'Name4' ),
'4' => array ('fid' => 3, 'tid' => 9, 'name' =>'Name5' ) 
);
function changeArrayStyle($arr){
foreach($arr as $key=>$value){
$result[$value['fid']][]=$value;
}
return array_values($result);
}
$arr2=changeArrayStyle($arr1);
echo "

";     <br>var_dump($arr2);        <p><br><br>5. 请简述数据库设计的范式及应用。<br>一般第3范式就足以,用于表结构的优化,这样做既可以避免应用程序过于复杂同时也避免了SQL语句过于庞大所造成系统效率低下。 <br>ANSWER:<br>第一范式:若关系模式R的每一个属性是不可再分解的,再属于第一范式。<br>第二范式:若R属于第一范式,且所有的非码属性都完全函数依赖于码属性,则为第二范式。<br>第三范式:若R属于第二范式,且所有的非码属性没有一个是传递函数依赖于候选码,则属于第三范式。<br>6.一个表中的Id有多个记录,把所有这个id的记录查出来,并显示共有多少条记录数,用SQL语句及视图、存储过程分别实现。<br>存储过程: // 内容来自技术世界www.js4j.com 专业技术//</p>    <p class="sycode">     DELIMITER //     <br>create procedure proc_countNum(in columnId int,out rowsNo int)     <br>begin     <br>select count(*) into rowsNo from member where member_id=columnId;         <br>end     <br>call proc_countNum(1,@no);     <br>select @no;    </p>    <p><br>视图:<br>create view v_countNum as select member_id,count(*) as countNum from member group by member_id<br>select countNum from v_countNum where member_id=1<br>7 表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选择C列。</p>    <p> </p>    <p class="sycode">     select     <br>case     <br>when first_name>middle_name then     <br>case when first_name>last_name then first_name     <br>else last_name end     <br>else     <br>case when middle_name>last_name then middle_name else last_name     <br>end     <br>end as name     <br>from member    </p>    <p><br>8请简述项目中优化sql语句执行效率的方法,从哪些方面,sql语句性能如何分析?<br>ANSWER: sql优化有鸟用,不如直接加索引。<br>9 如果模板是用smarty模板。怎样用section语句来显示一个名为$data的数组。比如:</p>    <p> </p>    <p class="sycode">     $data = array(     <br>[0] => array( [id]=8 [name]=’name1′)     <br>[1] => array( [id]=10 [name]=’name2′)     <br>[2] => array( [id]=15 [name]=’name3′)     <br>……     <br>)    </p>    <p><br>写出在模板页的代码? 若用foreach语句又要怎样显示呢?<br>占无答案.<br>10 写一个函数,能够遍历一个文件夹下的所有文件和子文件夹。(目录操作)</p>    <p> </p>    <p class="sycode">     $d = dir(dirname(__file__));     <br>//echo "Handle: " . $d->handle . "\n";     <br>//echo "Path: " . $d->path . "\n";     <br>while ( false !== ($entry = $d->read ()) ) {     <br>echo $entry . "<br>";     <br>}     <br>$d->close ();      </p>    <p><br><br>11 两张表 city表和province表。分别为城市与省份的关系表。<br>city:<br>id City Provinceid<br>1 广州 1<br>2 深圳 1<br>3 惠州 1<br>4 长沙 2<br>5 武汉 3<br>………. 广州 // 本文来自技术世界www.js4j.com 技术教程// <br>province:<br>id Province<br>1 广东<br>2 湖南<br>3 湖北<br>……….<br>(1) 写一条sql语句关系两个表,实现:显示城市的基本信息。?<br>(2) 显示字段:城市id ,城市名, 所属省份 。<br>如:<br>Id(城市id) Cityname(城市名) Privence(所属省份)<br>。。。。。。。。。<br>。。。。。。。。。<br>(2)如果要统计每个省份有多少个城市,请用group by 查询出来。?<br>显示字段:省份id ,省份名,包含多少个城市。<br>ANSWER:<br>1.select A.id,A.Cityname,B.Province from city A,province B where A.provinceid=B.id<br>2.select B.id,B.Province,count(*) as num from city A,province B where A.provinceid=B.id group by B.id</p>    <br>12. 按照你的 经验 请简述软件工程进行软件开发的步骤。以下 工具 Rational Rose、PowerDesigner、Project、VSS或CVS、TestDirector使用过那种,有缺点是什么?    <br> 公司 用dbdesigner及cvs,测试管理工具用的是Mantis    <br>13. 请简述操作系统的线程与进程的区别。列举LINUX下面你使用过的软件?    <br>14. 请使用伪语言结合数据结构冒泡排序法对以下一组数据进行排序 10 2 36 14 10 25 23 85 99 45。  // 本文来自技术世界www.js4j.com 技术教程//    <p> </p>    <p class="sycode">     function bubble_sort(& $arr){     <br>$number=count($arr);     <br>for($i=0;$ifor($j=0;$j   if($arr[$j]>$arr[$j+1]){     <br>    $tmp=$arr[$j];     <br>    $arr[$j]=$arr[$j+1];     <br>    $arr[$j+1]=$tmp;     <br>   }     <br>}     <br>}      <br>}     <br>$str="10 2 36 14 10 25 23 85 99 45";     <br>$arr=explode(" ",$str);     <br>bubble_sort($arr);     <br>echo "</p><pre class="brush:php;toolbar:false">";     <br>var_dump($arr);        <p> </p>      
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
11 Best PHP URL Shortener Scripts (Free and Premium)11 Best PHP URL Shortener Scripts (Free and Premium)Mar 03, 2025 am 10:49 AM

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Introduction to the Instagram APIIntroduction to the Instagram APIMar 02, 2025 am 09:32 AM

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, ReactBuild a React App With a Laravel Back End: Part 2, ReactMar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Announcement of 2025 PHP Situation SurveyAnnouncement of 2025 PHP Situation SurveyMar 03, 2025 pm 04:20 PM

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

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)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment