PHP Basics: Introduction to PHP Programming

WBOY
Release: 2023-09-03 19:08:01
Original
917 people have browsed it
<p></p> <div class="content-block-wysi" content-block-type="Wysi"> <p> There is no denying that our industry is an extremely difficult one. Ever considered learning a second language? Well, how about five? If you want to become a modern web developer, this is what you need. With this in mind, if you're not careful, you may soon find yourself overwhelmed as you blindly stare at countless confusing blog posts or technical books. <!--more--></p> <blockquote class="pullquote"> <p> As with anything, the key is to take it one step at a time. </p> </blockquote> <p>As with anything, the key is to take one step at a time. Do you blame yourself for not learning to speak English in a month? of course not. Then apply that same level of thinking to your programming journey. These things take time, but, as long as you keep moving forward, you'll get there in no time. Don't stop! </p> <p>The first step is HTML. Learn what <code>&amp;lt;div&amp;gt;</code> does. Learn how to build content using semantic tags. Build a basic, unstyled web page. </p> <p> As you may have guessed, the second step is CSS. Learn how to style elements on your page. Learn what "separation of concerns" means and how it applies to HTML and CSS. Complete your first simple website. </p> <p>The third step is for developers to start branching into their own areas of expertise. At this point, you can dive into the world of JavaScript, which is booming like never before. Alternatively, you can focus your efforts on the backend. </p> <blockquote> <p>Confused about the difference between <em>frontend</em> and <em>backend</em>? Think of the front end as the tip of the iceberg that led to the sinking of the Titanic. It is the part of the application that is visible to the user and can be interacted with. The backend, on the other hand, handles everything from persistence to validation to routing. </p> </blockquote> <p> For the purposes of this article, we'll assume you chose the latter option; server-side, that's it! </p> <blockquote class="pullquote"> <p> There is no denying that PHP dominates the web. </p> </blockquote> <p>Unfortunately, you once again run into some roadblocks. Should you choose the most popular option - PHP? Where's Ruby? The cool kids seem to prefer that these days. Then again, what if you have a beard? Is Python the right choice? But most importantly, how can you possibly make a choice when you have zero experience? </p> <p> In this case - in the author's opinion - there is no wrong choice. Of course, there's nothing stopping you from changing direction. In fact, all developers are encouraged to learn multiple languages! The key now, however, is to pick just one and learn it well. </p> <p>Although PHP is indeed not the most beautiful language, it is undeniable that it dominates the web. In fact, it is the most popular scripting language in the world. The benefit of this is that you can rest assured that every PHP issue has been raised, resolved, and documented. It's comforting to know. Even though you're at the most vulnerable stage of your learning, there's a large, friendly community on your doorstep, ready to help. Even better, PHP is experiencing an unprecedented modern renaissance thanks to tools like Composer and Laravel. </p> <hr> <h2>What is PHP? </h2> <p>PHP, short for <em>PHP: Hypertext Preprocessor</em> (yes, developers love their recursion jokes), is a scripting language built specifically for the web. Chances are, though, that this still means nothing to you. Scripting language? ah? When would you choose PHP over simple HTML? Well, maybe an example. Assuming you have successfully installed PHP, create the <code>index.php</code> file in a new folder on your desktop and add: </p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">&amp;lt;?php echo 'Hello world'; </pre><div class="contentsignin">Copy after login</div></div> <blockquote> <p>Yes, this is the ubiquitous "<em>hello world</em>" example that you will become very familiar with as your skills advance. There's one for every language/framework/tool! </p> </blockquote> <p>In order to run this code, use PHP's built-in server. Switch to your favorite command line tool (Terminal, for Mac users), <code>cd</code> to the project folder, and start the server using <code>php -S localhost:8888</code>. This command translates to "<em>Run the server and make it accessible through a browser on localhost, port 8888". Come and try it out! Open Google Chrome, browse to <code>localhost:8888</code>, you will see "Hello world*" on the page! pretty! <code>echo</code> is a language construct that does nothing but output a given value. </p> <blockquote> <p><strong>Tip</strong>: MAMP and WAMP are excellent one-click solutions for installing PHP, MySQL, and Apache on your Mac or PC without having to fumble around the command line. They can be useful options in the early stages of your studies. </p> </blockquote> <p><img src="https://img.php.cn/upload/article/000/887/227/169373924846732.png" alt="PHP 基础知识:PHP 编程简介" /></p> <p><!-- end img --></p> <p>诚然,这并不是世界上最令人兴奋的事情。事实上,您可能会想,“<em>为什么我不能将“Hello world”直接写入 HTML 页面,从而完全不需要 PHP?</em>”这是真的;对于这个例子来说,它没有任何作用。然而,当输出本质上是动态的时,像 PHP 这样的脚本语言就变得特别有用。如果您希望问候语引用通过 URL 的查询字符串(地址栏中问号后面的文本)传递的值,而不是 <em>world</em>,该怎么办?这是一个更新的示例,它就实现了这一点!</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">&amp;lt;?php echo 'Hello, ' . $_GET['person']; </pre><div class="contentsignin">Copy after login</div></div> <p>啊,这引入了一些新技术。首先,分隔 <em>Hello</em> 字符串和令人困惑的 <code>$_GET</code> 的单个句点允许您连接(或分组)值。在本例中,我们希望打印“<em>Hello, *”,然后打印 <code>$_GET['person']</code> 表示的值。这就是我们所说的超全局数组。为了简单起见,可以将其视为从 URL 的查询字符串*获取</em>值的一种方法。</p> <p>通过加载 <code>localhost:8888/?person=Joe</code> 来测试这一点。如果配置正确,网页现在应该显示“<em>Hello, Joe</em>”。通过将 <code>Joe</code> 替换为您自己的名称来尝试一下。请注意每次刷新页面时输出如何更新?这对于静态 HTML 来说根本不可能实现。</p> <p>成熟编程的关键之一是考虑代码中每一个可能的路径。例如,如果没有 <code>person</code> 密钥可用怎么办?也许查询字符串被完全省略了。在这种情况下,肯定会抛出错误,因为 <code>person</code> 键不存在。解决办法是什么?虽然这确实只是一个简单的例子,但考虑所有可能的结果仍然很重要。让我们提供一个默认值。</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">&amp;lt;?php if (isset($_GET['person'])) { $person = $_GET['person']; } else { $person = 'Joe'; } echo 'Hello, ' . $person; </pre><div class="contentsignin">Copy after login</div></div> <p>尽管有更简化的方法可以实现这一点,但上面的示例是一个很好的起点。这也是您对条件语句的第一次介绍。以与处理现实生活中的场景相同的方式处理代码。例如,“<em>如果我们没有牛奶,就去商店。否则,就呆在家里。</em>”这种思路可以使用以下逻辑转换为 PHP:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">$outOfMilk = true; if ($outOfMilk) { echo 'Going out to the store.'; } else { echo 'Breakfast is served.' } </pre><div class="contentsignin">Copy after login</div></div> <p>在这段代码中,只会将一行文本打印到屏幕上。变量值(动态值)<code>$outOfMilk</code> 将确定控制流。</p> <blockquote> <p><strong>提示:</strong>要在 PHP 中声明变量,请在任何名称前添加美元符号。作为最佳实践,选择可读的变量名称而不是神秘的替代名称。</p> </blockquote> <p>回到前面的例子,只要设置了 <code>$_GET['person']</code> (可以将其视为“可用”的伪名),然后创建一个新的 <code>$person</code> 变量 equal到它的价值。否则,应用默认值。如果您返回到浏览器,它现在应该可以正常运行,无论查询字符串中是否存在 <code>person</code> 键。</p> <h3>安全</h3> <p>不幸的是,我们仍然没有回家。一个关键的编程最佳实践是将安全性置于每项操作的最前沿。即使有了这个令人难以置信的基本示例,我们也为网络上最普遍的安全问题之一打开了大门:XSS(跨站脚本)。对此的真正理解绝对超出了本入门课程的范围(整本书都写过它),但是,这里有一个基本说明:如果 <code>$_GET['person']</code> 等于而不是字符串怎么办,但是一个脚本?</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">http://localhost:8888/?person=&amp;lt;script&amp;gt;alert('ATTACK!')&amp;lt;/script&amp;gt; </pre><div class="contentsignin">Copy after login</div></div> <p>由于该值尚未被清理,因此在执行时,在某些浏览器中会显示警告框。</p> <blockquote> <p>基于 Webkit 的浏览器(例如 Chrome 和 Safari)现在可以提供针对此类攻击的保护。然而,情况并非总是如此,并且在 Firefox 和 Internet Explorer 中仍然如此。</p> </blockquote> <p><img src="https://img.php.cn/upload/article/000/887/227/169373924861096.png" alt="PHP 基础知识:PHP 编程简介" /></p> <p>哎呀!我们不能这样。虽然现代社会表明一个人在被证明有罪之前是无辜的,但对于编程世界来说却并非如此。所有用户输入在经过净化之前都是有罪的!这是一个更新的示例,它执行此操作:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">&amp;lt;?php if (isset($_GET['person'])) { $person = $_GET['person']; } else { $person = 'Joe'; } echo 'Hello, ' . htmlspecialchars($person, ENT_QUOTES); </pre><div class="contentsignin">Copy after login</div></div> <p>通过此修改,如果有人尝试 XSS 攻击,我们将做好准备! <code>htmlspecialchars</code> 是一个本机 PHP 函数,可将各种符号转换为其实体对应部分。 <code>&amp;</code> 变为 <code>&amp;</code>、<code><</code> 变为 <code><</code> 等。这使其成为提供额外安全性的完美工具。 <code><script></code> 如果在执行前转换为 <code><script></code> 则没有任何意义。用户将简单地看到:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">Hello, &amp;lt;script&amp;gt;alert('ATTACK!')&amp;lt;/script&amp;gt; </pre><div class="contentsignin">Copy after login</div></div> <p>太棒了;没有造成任何伤害!</p> <hr> <h2>函数</h2> <p>虽然 PHP 附带了大量本机函数,但有时您肯定需要自己的函数。幸运的是,编写它们很容易。</p> <blockquote> <p>将函数视为可重用的逻辑片段,可以将其抽象出来,以便可以使用可读的名称来识别和调用它。</p> </blockquote> <p>也许您经营一家夜总会(如果您正在阅读本文,则不太可能!),并且需要一种简单的方法来接受一个人的出生日期,并计算他或她是否至少有 21 岁。自定义函数将是完成此任务的绝佳方法。</p> <p>第一步是定义一个新函数,名为 <code>isAdult</code>。函数可以接受外部输入,然后可以对其进行操作。这允许函数返回的数据是动态的。在这种情况下,要确定一个人是否是成年人,我们需要知道他们的出生年份。最后一步是返回 <code>true</code> 或 <code>false</code>,具体取决于当前年份减去该人的出生日期是否至少为二十一。</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">function isAdult($yob) { $currentYear = 2013; return $currentYear - $yob &amp;gt;= 21; } </pre><div class="contentsignin">Copy after login</div></div> <p>其实很简单!现在,我们只需要将其传递给保镖即可。可以通过引用其名称并后跟一组括号来触发或调用函数:<code>isAdult()</code>。但是,如果函数需要参数,那么您可以在这些括号内指定它,如下所示:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">if (isAdult(1985)) { echo 'Come on in!'; } else { echo 'Please leave now, before I call your mother.'; } </pre><div class="contentsignin">Copy after login</div></div> <p>这个 <code>isAdult</code> 函数有一个明显的问题。当前年份已被硬编码。当然,它会在整个 2013 年有效,但明年呢?看来这个值也需要是动态的。 PHP提供了一个<code>date</code>函数,可以用来计算当前年份。因此,该功能可能会更新为:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">function isAdult($yob) { $currentYear = date('Y'); return $currentYear - $yob &amp;gt;= 21; } </pre><div class="contentsignin">Copy after login</div></div> <hr> <h2>数组</h2> <p>几个月过去了,现在夜总会的生意比以往任何时候都好。事实上,它做得太好了,以至于保镖无法跟上。如果他可以一次筛选一组人,他的工作可能会更容易。</p> <p>将数组视为相关数据的容器。您甚至可以将其称为列表:推文列表、一组家庭成员、一组出生日期。</p> <p>最新版本的 PHP (5.4) 中的数组可以使用括号内的逗号分隔列表来定义,如下所示:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">$group = [1985, 1990, 1992, 1997]; </pre><div class="contentsignin">Copy after login</div></div> <p>这个单个 <code>$group</code> 变量现在包含多个出生日期。可以通过指定索引来访问其中的值,例如 <code>$group[0]</code>。数组就是我们所说的从零开始的数组。在翻译中,这意味着数组中的第一项或键的索引为零。因此,要访问 1992 年的值,您可以引用 <code>$group[2]</code>。</p> <p>现在,保镖可以快速过滤这些出生日期,并计算是否允许该人进入或拒绝他们。 <code>foreach</code> 语句可用于此类过滤。</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">$group = [1985, 1990, 1992, 1997]; foreach($group as $yob) { if (isAdult($yob)) { echo 'Come on in!'; } else { echo 'Please leave now, before I call your mother.'; } } </pre><div class="contentsignin">Copy after login</div></div> <p>注意保镖如何声明 <code>group</code> 中的出生年份 <code>foreach</code> 人应包含在变量 <code>$yob</code> 中。接下来,正如他之前所做的那样,他将该值传递给 <code>isAdult</code> 函数,并相应地继续。</p> <p>不过,当保镖无法确定此人的出生年份和姓名之间的联系时,他可能会感到困惑。 PHP 还允许关联数组,它提供了将给定值与键关联起来所需的功能。这是一个例子:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">$group = [ 'John' =&amp;gt; 1985, 'Susan' =&amp;gt; 1990, 'Joe' =&amp;gt; 1992, 'Sara' =&amp;gt; 1997 ]; </pre><div class="contentsignin">Copy after login</div></div> <p>这样更好。作为额外的好处,保镖现在知道了这个人的名字,可以对这个人更加友好一点。</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">$group = [ 'John' =&amp;gt; 1985, 'Susan' =&amp;gt; 1990, 'Joe' =&amp;gt; 1992, 'Sara' =&amp;gt; 1997 ]; foreach($group as $name => $yob) { if (isAdult($yob)) { echo "Come on in, $name!"; } else { echo "Please leave now, $name, before I call your mother."; } } </pre><div class="contentsignin">Copy after login</div></div> <blockquote> <p>在双引号内存储字符串时,您可以嵌套变量而不是使用连接。这可以提供更具可读性的语法。</p> </blockquote> <hr> <h2>课程</h2> <p>面向对象的编程远远超出了本教程的范围,但是,类仍然值得一提。现在,将它们视为相关属性和方法的简单容器。例如,代表单个人的类可能如下所示:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">class Person { public $name; public $age; public function __construct($name, $age) { $this-&amp;gt;name = $name; $this-&amp;gt;age = $age; } } </pre><div class="contentsignin">Copy after login</div></div> <p>注意到 <code>__construct()</code> 方法了吗?这被称为魔术方法,实例化后会立即触发。当此方法触发时,它将接受名称和年龄,然后将其附加到对象。</p> <p>要使用此类,请尝试:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">$me = new Person('Jeffrey', 28); </pre><div class="contentsignin">Copy after login</div></div> <p>这将创建 <code>Person</code> 类的新实例。该实例存储在 <code>$me</code> 变量中,可以称为对象。现在,没有什么可以阻止您创建此类的多个实例 - 事实上,在现实世界的项目中,您会这样做!该类只是一个蓝图。</p> <p>但此时,该类还没有太大用处。让我们添加一个方法或函数来指定一个人的配偶。</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">class Person { public $name; public $age; public $spouse; public function __construct($name, $age) { $this-&amp;gt;name = $name; $this-&amp;gt;age = $age; } public function marry(Person $spouse) { $this-&amp;gt;spouse = $spouse; } } $me = new Person('Jeff', 28); $her = new Person('Allison', 28); $me-&amp;gt;marry($her); </pre><div class="contentsignin">Copy after login</div></div> <p>此修改后的代码现在包含一个 <code>marry()</code> 方法,该方法将更新对象上的 <code>$spouse</code> 属性。现在,两个人之间有了直接联系。</p> <blockquote> <p>如果方法参数前面有一个类名(<code>Person $spouse</code>),称为类型提示,则表明该参数必须是给定类的实例,否则将引发错误。</ p> </blockquote> <p>要获取我配偶的名字,您可以这样写:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">echo $me-&amp;gt;spouse-&amp;gt;name; // Allison </pre><div class="contentsignin">Copy after login</div></div> <p>面向对象编程的概念比这更深入,但现在保持简单。它有助于将类视为单数名词:推文、用户、客户或文件。</p> <p>对这种模式的真正欣赏只会随着时间的推移而出现。</p> <h3>动手实践</h3> <p>测试您新发现的技能。您如何在页面上为用户注册和显示推文?好吧,第一步可能是定义一个代表单个 <code>Tweet</code> 的类。此类应存储推文正文的属性及其发布日期。此外,还应确保推文正文不超过 140 个字符。这是此类课程的第一次尝试:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">class Tweet { public $body; public $pubDate; public function __construct($body) { $this-&amp;gt;setBody($body); $this-&amp;gt;setPubDate(new DateTime); } public function setBody($body) { if (strlen($body) &amp;gt; 140) { throw new InvalidArgumentException; } $this-&amp;gt;body = $body; } public function setPubDate(DateTime $date) { $this-&amp;gt;pubDate = $date-&amp;gt;format('Y/m/d H:i:s'); } } </pre><div class="contentsignin">Copy after login</div></div> <p>虽然一开始看起来可能令人不知所措,但请稍微研究一下这段代码,并尝试了解每一步发生的情况。您可能会发现它非常可读!</p> <p>一个有趣的新功能源于 <code>setBody</code> 方法。如果提供的文本超过 140 个字符(我们可以使用 PHP 的 <code>strlen</code> 函数计算),那么我们应该对此表示反对,因为它违反了推文的规则。可以使用语法 <code>throw new ExceptionType</code> 抛出异常。</p> <p>现在我们有了一个足够合适的推文容器,我们可以创建几条推文,将它们存储在一个数组中,然后最终使用 <code>foreach</code> 语句将它们呈现在页面上。</p > <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">$tweets = []; # add two new tweets to the array $tweets[] = new Tweet('Going to the store.'); $tweets[] = new Tweet('Back from the store!'); # Filter through, and display on page. foreach($tweets as $tweet) { echo &amp;quot;&amp;lt;h2&amp;gt;{$tweet-&amp;gt;body}&amp;lt;/h2&amp;gt;&amp;quot;; echo &amp;quot;&amp;lt;p&amp;gt;Posted on: {$tweet-&amp;gt;pubDate}&amp;lt;/p&amp;gt;&amp;quot;; } </pre><div class="contentsignin">Copy after login</div></div> <p>在浏览器中查看输出后,您应该看到类似以下内容的内容:</p> <p><img src="https://img.php.cn/upload/article/000/887/227/169373924876164.png" alt="PHP 基础知识:PHP 编程简介" /></p> <p>很好,但是我们如何保存这些推文?</p> <hr> <h2>存储</h2> <p>到目前为止,您已经学习了基础知识:变量、条件、函数、数组、类。还有更多内容需要介绍,但您应该根据需要自行研究。学习的下一步就是坚持。例如,您如何保留所有推文的日志?不<em>记住</em>推文的推文服务是一个糟糕的服务!这就是数据库的想法发挥作用的时候。</p> <p>将数据库表视为 Excel 电子表格。它可以包含任意数量的字段,例如人员的姓名、年龄或邮寄地址。然而,PHP 本身并不提供这种存储。相反,最常见的选择是 MySQL,它是世界上最流行的开源数据库。</p> <blockquote> <p>安装 MySQL 不属于本教程的范围。相反,请参阅 Nettuts+ 上的本教程以获取完整的演练。</p> </blockquote> <p>下面是一个简化的示例,可帮助您开始从数据库表中安全地获取行。如果它看起来势不可挡,请不要担心。 MySQL 是您要学习的第二门新语言。 PHP 的 PDO API 以及查询语言本身需要时间学习。</p> <p>首先,您需要一种连接数据库的方法。</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">function connect() { $conn = new PDO( 'mysql:host=localhost;dbname=DB_NAME', 'USERNAME', 'PASSWORD' ); $conn-&amp;gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); return $conn; } </pre><div class="contentsignin">Copy after login</div></div> <blockquote> <p>PDO 是 PHP 用于连接 MySQL 数据库的三个可用 API 之一。</p> </blockquote> <p>接下来,我们将添加一个辅助函数来从 tweets 表中获取所有记录。请密切注意 <code>query</code> 方法的参数 <code>SELECT * FROM tweets</code>。这是一种用于查询数据库的特殊语言。在本例中,我们使用 <code>*</code> 符号来引用所有行。因此,我们从表中选择所有行,名为 <code>tweets</code>。</p> <p>此函数准备查询,然后获取完整的结果集。</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">function fetchTweets($conn) { $stmt = $conn-&amp;gt;query('SELECT * FROM tweets'); return $stmt-&amp;gt;fetchAll(PDO::FETCH_OBJ); } </pre><div class="contentsignin">Copy after login</div></div> <p>现在,阶段设置完毕,我们只需要相应地调用函数即可。</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;"># Connect to the DB $conn = connect(); # Fetch all rows from attendees table var_dump(fetchTweets($conn)); </pre><div class="contentsignin">Copy after login</div></div> <p>转储变量内容的一个简单方法是使用 <code>var_dump</code> 函数。如果将 <code>fetchTweets($conn)</code> 的输出传递给此函数,在浏览器中查看它时,您将看到类似以下内容的内容:</p> <p><img src="https://img.php.cn/upload/article/000/887/227/169373924910979.jpg" alt="PHP 基础知识:PHP 编程简介" /></p> <p><code>var_dump</code> 对于调试很有帮助,但出于生产目的,最好过滤结果,并将它们正确呈现在页面上。您已经熟悉的 <code>foreach</code> 语句将很好地处理这项工作!</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbal:false;">$tweets = fetchTweets($conn); foreach($tweets as $tweet) { echo &amp;quot;&amp;lt;h2&amp;gt;{$tweet-&amp;gt;body}&amp;lt;/h2&amp;gt;&amp;quot;; echo &amp;quot;&amp;lt;p&amp;gt;{$tweet-&amp;gt;pubDate}&amp;lt;/p&amp;gt;&amp;quot;; } </pre><div class="contentsignin">Copy after login</div></div> <hr> <h2>结论</h2> <p>与任何技能一样,编写流利的 PHP 只需要您的时间。可能需要数百个小时才能完全理解,但这没关系。这很有趣,对吧?应该是这样!</p> <p>最好的学习方法就是实践。构建废弃的项目,就像它们已经过时一样!本教程中概述的技术将带您完成第一阶段,但是,随着您技能的进步,您肯定会继续学习更高级的主题,例如 PHP 框架、设计模式和测试驱动开发。玩得开心!</p> <h3>建议的 Tuts+ 优质资源</h3> <ul> <li> 现代 PHP 开发人员 </li> <li> PHP 基础知识 </li> <li> SQL 要点<p> </p> </li> </ul> </div>

The above is the detailed content of PHP Basics: Introduction to PHP Programming. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!