Home >Backend Development >PHP Tutorial >Driving skills for newbies on the road PHP newbies on the road (3)

Driving skills for newbies on the road PHP newbies on the road (3)

WBOY
WBOYOriginal
2016-07-29 08:34:581223browse

Learn PHP from a simple program
The PHP site’s online tutorials are already great. This part of the article will make you familiar with PHP. It's impossible for me to miss anything. My purpose is only to allow you to quickly start your PHP programming. ​
3.1 First Conditions
​ You must first have a working web server that supports PHP. I assume that all PHP files on your server have the extension .php3.
3.2 Installation of PHP
For the installation and configuration of PHP, you can check the special article "Complete PHP Installation Guide" on Taoba website.
3.3 Grammar
  From a syntactic point of view, PHP language is similar to C language. It can be said that PHP draws on the grammatical features of C language and is improved from C language. We can mix PHP code and HTML code. Not only can we embed PHP scripts into HTML files, we can even embed HTML tags in PHP scripts. Here are a few approaches you can take. You can choose whichever one works best for you and stick with it!
Separate from HTML
The following are the methods that can be used:


".
Statements
Like Perl and C, statements are separated by ";" in PHP. Those separate tags from HTML also indicate the end of a statement.
Comments
PHP supports C, C++ and Unix style comments:
/* C, C++ style multi-line comments*/
// C++ style single line comments
# Unix style single line comments
echo and print
PHP and HTML are the simplest The interaction is achieved through print and echo statements. In actual use, the functions of print and echo are almost exactly the same. It can be said that wherever one can be used, the other can also be used. However, there is still a very important difference between the two: in the echo function, multiple strings can be output at the same time, while in the print function, only one string can be output at the same time. At the same time, the echo function does not require parentheses, so the echo function is more like a statement than a function. Let's take a look at the following example:
$a="hello";
$b="world";
echo "a","b";
print "a","b";
?>
After watching the operation of this code with a browser, you will see the following results:
aba
Parse error: parse error in d:adminmyphphometest.php3 on line 5
This shows that this code does not It cannot be completely explained. The error occurs in the fifth line of the code: "print "a", "b";".
3.4 A simple example
With the knowledge we have learned, you can write the simplest program to output a word that is perhaps the most famous word in the programming world


<br> <br><H1> <br></H1> <br></H1> HR> <br><? <br>// Single line C++ style comment <br>/* <br>printing the message <br>*/ <br>echo "Hello World!"; <br># Unix style single line comment <br>?> <br></BODY> </HTML> <br> <br> The above introduces the driving skills for novices on the road. PHP novices on the road (3), including the content of driving skills for novices on the road. I hope it will be helpful to friends who are interested in PHP tutorials. <br> <br> <br></p></div><div class="nphpQianMsg"><div class="clear"></div></div><div class="nphpQianSheng"><span>Statement:</span><div>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</div></div></div><div class="nphpSytBox"><span>Previous article:<a class="dBlack" title="http www.chinapost.com.cn phpini Chinese version" href="https://m.php.cn/faq/321152.html">http www.chinapost.com.cn phpini Chinese version</a></span><span>Next article:<a class="dBlack" title="http www.chinapost.com.cn phpini Chinese version" href="https://m.php.cn/faq/321154.html">http www.chinapost.com.cn phpini Chinese version</a></span></div><div class="nphpSytBox2"><div class="nphpZbktTitle"><h2>Related articles</h2><em><a href="https://m.php.cn/article.html" class="bBlack"><i>See more</i><b></b></a></em><div class="clear"></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-6t+ed+2i-1n-4w" data-ad-client="ca-pub-5902227090019525" data-ad-slot="8966999616"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><ul class="nphpXgwzList"><li><b></b><a href="https://m.php.cn/faq/1.html" title="How to use cURL to implement Get and Post requests in PHP" class="aBlack">How to use cURL to implement Get and Post requests in PHP</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/1.html" title="How to use cURL to implement Get and Post requests in PHP" class="aBlack">How to use cURL to implement Get and Post requests in PHP</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/1.html" title="How to use cURL to implement Get and Post requests in PHP" class="aBlack">How to use cURL to implement Get and Post requests in PHP</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/1.html" title="How to use cURL to implement Get and Post requests in PHP" class="aBlack">How to use cURL to implement Get and Post requests in PHP</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/2.html" title="All expression symbols in regular expressions (summary)" class="aBlack">All expression symbols in regular expressions (summary)</a><div class="clear"></div></li></ul></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="5027754603"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><footer><div class="footer"><div class="footertop"><img src="/static/imghwm/logo.png" alt=""><p>Public welfare online PHP training,Help PHP learners grow quickly!</p></div><div class="footermid"><a href="https://m.php.cn/about/us.html">About us</a><a href="https://m.php.cn/about/disclaimer.html">Disclaimer</a><a href="https://m.php.cn/update/article_0_1.html">Sitemap</a></div><div class="footerbottom"><p> © php.cn All rights reserved </p></div></div></footer><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script></div><script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><script>jQuery.fn.wait = function (func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = this.selector, //选择器 _iIntervalID; //定时器id if( this.length ){ //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function() { if(!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if( _self.length ) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this; } $("table.syntaxhighlighter").wait(function() { $('table.syntaxhighlighter').append("<p class='cnblogs_code_footer'><span class='cnblogs_code_footer_icon'></span></p>"); }); $(document).on("click", ".cnblogs_code_footer",function(){ $(this).parents('table.syntaxhighlighter').css('display','inline-table');$(this).hide(); }); $('.nphpQianCont').viewer({navbar:true,title:false,toolbar:false,movable:false,viewed:function(){$('img').click(function(){$('.viewer-close').trigger('click');});}}); </script></body><!-- Matomo --><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="https://tongji.php.cn/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '9']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!-- End Matomo Code --></html>