PHP习题网站

 初级到中级的PHP练习

1. 是练习,不是教程

网上有许多非常好的PHP教程。但PHP习题却不多。对此本网(http://phpexercises.com)站提供了多达31PHP练习。 选择左边的菜单中的一个题开始做吧。

2. 习题原理

习题让你按需求写出相应代码来测试你相关的PHP知识。 当你完成后,可以点击查看参考答案。 参考代码的也可显示输出。 如果你需要教程辅导,请查阅资源(Resourceshttp://phpexercises.com/web-resources.html)页面列出的PHP教程网络资源。 再来测试你的学习成果。

这些PHP习题包含从最简单的("Hellow world!")到复杂的代码。后面一些更难的需求基于前面简单的习题所涉及的知识。如果你跳着做习题,发现不会做了,就往前一个或前两个习题再尝试。请仔细阅读参考答案里的注释内容对代码的解释。如果你发现了不同于参考答案的实现方法,那非常好。只要保证你理解题目所要测试的PHP相关语法知识。

3. 你需要准备什么

我们相信如果你在寻找PHP练习,那么你可能已经有服务器进行过一些实践了。 如果没有,请参见本站(Your Setup: http://phpexercises.com/php-setup-testing-exercises.html)指引你开始。

4. 示例习题

数组 #7 多维数组

多维数组即为包含数组的数组。这点很重要,多维数组的使用范围法经常超出数组的基本用法。

这个习题有两部分。一是找到习题#5中的数组(大城市),将它转化为多维数组。 它会成为一张表中的数据。

将数组(大城市)重写成多维数组$multiCity. 第一个子数组将成为包含标签,城市,国家,大陆的新数组。(这些会成为这个习题另一部分的关键)接下来的每个子数组都会包含这三项对应11个子数组。

以下是数组的内容:City, Country, Continent; Tokyo, Japan, Asia; Mexico City, Mexico, North America; New York City, USA, North America; Mumbai, India, Asia; Seoul, Korea, Asia; Shanghai, China, Asia; Lagos, Nigeria, Africa; Buenos Aires, Argentina, South America; Cairo, Egypt, Africa; London, UK, Europe.

未完。。。

 

原文:
Beginner to Intermediate PHP Exercises

Exercises, not Tutorials

The Web is full of excellent PHP tutorials. PHP exercises? Not so much. This site begins to fill that gap with 31 exercises. Choose one from the menu on the left and get started!


How It Works

Come here to test your PHP knowledge by writing scripts as requested. When you are ready, click the button to see the PHP answer script. The answer script output is also available. If you need tutorials, check out one of the PHP tutorial sites listed on the Resources page, then come back and try out what you learned!

The PHP programming exercises progress from the simplest scripts ("Hello world!") to more complex. More difficult requests build on skills included in earlier ones. If you jump ahead and find yourself stuck, go back one or two. Be sure to read the comments in the answer script for some explanation. If you find that a different approach gets the same results, great! Just be sure you understand the PHP syntax the problem was designed to test.


What You'll NeedWe assume that if you are looking for PHP exercises, you already have a server to practice with. If not, check out Your Setup for some tips on getting started.

Featured Exercise - Arrays #7: Multidimensional Array

Multidimensional arrays are arrays that contain arrays. Mastering these is important, as their use often extends beyond the basic uses of arrays.

This PHP exercise has two parts. In the first, you will take the large cities array from Arrays Ex. #5 and transform it into a multi-dimensional array. That will become the data in a table.

Rewrite the large cities array into a multi-dimensional array called $multiCity. The first sub-array will be completely new and include the labels, City, Country, Continent. (These will become the keys in the second half of this exercise.) Each of the succeeding sub-arrays should include those three items, one for each of the cities, for a total of 11 sub-arrays.

Here's the content for your array: City, Country, Continent; Tokyo, Japan, Asia; Mexico City, Mexico, North America; New York City, USA, North America; Mumbai, India, Asia; Seoul, Korea, Asia; Shanghai, China, Asia; Lagos, Nigeria, Africa; Buenos Aires, Argentina, South America; Cairo, Egypt, Africa; London, UK, Europe.

Go to exercise.

你可能感兴趣的:(PHP,职场,休闲,exercise)