{"id":6439,"date":"2019-09-10T08:34:00","date_gmt":"2019-09-10T08:34:00","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=6439"},"modified":"2022-05-08T12:07:23","modified_gmt":"2022-05-08T12:07:23","slug":"php-tutorial-for-beginners","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/php-tutorial-for-beginners\/","title":{"rendered":"PHP Tutorial for Beginners"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong><em>PHP FRONT TO BACK<\/em><\/strong><\/h2>\n\n\n\n<p><strong>What is PHP?<br>:-<\/strong> PHP: Hypertext Preprocessor(Recursive Acronym)<br>Server-Side Programming\/Scripting Language<br>Can be embedded directly within HTML (<strong>&lt;?php?&gt;<\/strong>)<br>Files use a \u201c<strong>.php<\/strong>\u201d file extension<\/p>\n\n\n\n<p><strong>How Does PHP Work?<\/strong><br>:- Client makes a request<br>Server runs PHP\/extensions<br>Query database if needed<br>Load other files if needed<br>Result is sent back to client<\/p>\n\n\n\n<p><strong>Why Use PHP?<\/strong><br>:- Easy To Learn Freedom<br>Free &amp; Open Source Frameworks<br>Great support Database Compatibility<br>Cross-Platform<\/p>\n\n\n\n<p><strong>What Can PHP do?<\/strong><br>:- Create dynamic page content Interact with databases<br>Interact with files on the server Access control<br>Collect &amp; process forms Encrypt data<br>Send\/ receive cookies Almost anything else<\/p>\n\n\n\n<p><strong>What Can You Build With PHP?<\/strong><br>:- Basic Websites Content Management Systems<br>Blog Type Websites Membership Websites<br>Shopping Carts Search Engines<br>Social Networks Backend APIs<\/p>\n\n\n\n<p>*** <strong>Install XAMPP Apache+MariaDB+PHP+Perl)(Latest version 7.1.1)<\/strong><br><strong>What is XAMPP?<\/strong><br>:- XAMPP is the most popular PHP development environment<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Install XAMPP his after open It and start Apache and MySQL go browser and search \u2013<br><strong>https:\/\/loclalhost<\/strong> (here uses only htdocxs file your xampp file)<\/li><\/ul>\n\n\n\n<p><strong>Variables<\/strong><br>:- Prefix $<br>Start with a letter or an underscore<br>only letter, numbers and underscores<br>Case sensitive<\/p>\n\n\n\n<p><strong>Data types<\/strong><br>:- String (ex- 12, 0, -34 etc.)<br>Integers (ex- 25.2654, 2.12, 41.54 etc.)<br>floats<br>Booleans (ex- true\/false)<br>Arrays (ex- multiple values in one single variable)<br>Objects (ex- hold programming objects)<br>Null (ex- hold only one value- NULL)<br>Resource (ex- special variable that hold references to resources external to PHP)<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>some Data type class<\/strong><ul><li>$Output = \u2018\u2026\u2026\u2026\u2019; (\u2026\u2026\u2026= You can use any word which you shown in desktop )<\/li><li>$num1 = 4; ()<\/li><li>$num2 = 10;<\/li><li>$sum = #num1 + $num2;<\/li><li>$strings1 = \u2018\u2026\u2026.\u2019;<\/li><li>$strings2 = \u2018\u2026\u2026.\u2019;<\/li><li>$greeting = string1. \u201d. $strings.\u2019!\u2019;<\/li><li>$greeting2 = \u201c$string1 $string2\u201d;<\/li><li>$string3 = \u2018They\\\u2019re Here\u201d;<br>:- define(\u2018GREETING\u2019, \u2018Hello Everyone\u2019, true);<br>:- echo greeting;<\/li><\/ul><\/li><li><strong>Array<\/strong>&#8211; basically variable that holds multiple values these are three types:-<br>1) Indexed<br>2) Associative<br>3) Multi-dimensional<\/li><\/ul>\n\n\n\n<p>** 1)<strong>Indexed<\/strong><br>some Indexed class<br>\u2013 $people = array(\u2018\u2026\u2026..\u2019, \u2018\u2026\u2026\u2026\u2019, \u2018\u2026\u2026..\u2019;<br>:- echo $people[3];<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>123456<\/td><td><code>- $ids = array (23, 55, 12);<\/code><code>:- echo $ids[2];<\/code>&nbsp;<code>- $cars= ['honda', 'Toyota', 'Ford';]<\/code><code>:- $cars[3]= 'Chevy';<\/code><code>:- echo $ids[3];<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>** 2) <strong>Associative arrays<\/strong><br>\u2013 $people = array(\u2018\u2026\u2026.\u2019=&gt; 35, \u2018\u2026\u2026..\u2019=&gt; 32, \u2018\u2026\u2026..\u2019 =&gt; 27);<br>:- $ids = [22 =&gt; \u2018\u2026\u2026.\u2019 ];<br>:- echo $ [\u2018\u2026\u2026\u2019];<\/p>\n\n\n\n<p>** 3) <strong>Multi Dimensional<\/strong><br>$cars = array(<br>array(\u2018Honda\u2019, 20, 10),<br>array (\u2018Toyota\u2019, 30, 20),<br>array (\u2018Ford\u2019, 23, 12),<br>);<br>echo $cars[1][2]<\/p>\n\n\n\n<p>Some Important Rational Operators-<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">==  equal to    <span class=\"hljs-number\">5<\/span>==<span class=\"hljs-number\">2<\/span>            <span class=\"hljs-keyword\">false<\/span>\n!=  not equal to    <span class=\"hljs-number\">5<\/span>!=<span class=\"hljs-number\">2<\/span>        <span class=\"hljs-keyword\">true<\/span>\n=== identical   $a===$b         <span class=\"hljs-keyword\">True<\/span> <span class=\"hljs-keyword\">if<\/span> $a is equal to $b\n                                <span class=\"hljs-keyword\">and<\/span> they are of the same\n&lt;&gt;  not euqal   $a &lt;&gt; $b        <span class=\"hljs-keyword\">true<\/span> <span class=\"hljs-keyword\">if<\/span> $a is not euqal to \n                                $b, <span class=\"hljs-keyword\">or<\/span> they are not of the same \n&lt;=&gt; spaceship   $a &lt;=&gt; $b       it returns <span class=\"hljs-number\">-1<\/span>, <span class=\"hljs-number\">0<\/span> <span class=\"hljs-keyword\">or<\/span> <span class=\"hljs-number\">1<\/span> when $a is \n                                respectivelt less than, equal to, <span class=\"hljs-keyword\">or<\/span> \n                                 greater than $b<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_16948\"><iframe loading=\"lazy\"  id=\"_ytid_44764\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_16948\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>PHP FRONT TO BACK What is PHP?:- PHP: Hypertext Preprocessor(Recursive Acronym)Server-Side Programming\/Scripting LanguageCan be embedded directly within HTML (&lt;?php?&gt;)Files use a \u201c.php\u201d file extension How Does PHP Work?:- Client makes&#8230; <\/p>\n","protected":false},"author":1,"featured_media":6440,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5150],"tags":[1570,5239,177,213],"class_list":["post-6439","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-beginners","tag-front-to-back","tag-php","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/6439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=6439"}],"version-history":[{"count":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/6439\/revisions"}],"predecessor-version":[{"id":25449,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/6439\/revisions\/25449"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/6440"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=6439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=6439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=6439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}