{"id":5645,"date":"2025-12-12T16:49:12","date_gmt":"2025-12-12T11:04:12","guid":{"rendered":"https:\/\/blog.eastlink.com.np\/?p=5645"},"modified":"2025-12-12T16:50:25","modified_gmt":"2025-12-12T11:05:25","slug":"introduction-to-php","status":"publish","type":"post","link":"https:\/\/blog.eastlink.com.np\/?p=5645","title":{"rendered":"Introduction to PHP"},"content":{"rendered":"<div style=\"margin-top: 0px; margin-bottom: 0px;\" class=\"sharethis-inline-share-buttons\" ><\/div><h2 data-start=\"314\" data-end=\"333\"><strong data-start=\"317\" data-end=\"333\">What is PHP?<\/strong><\/h2>\n<p data-start=\"334\" data-end=\"604\">PHP (Hypertext Preprocessor) is a <strong data-start=\"368\" data-end=\"402\">server-side scripting language<\/strong> used to create <strong data-start=\"418\" data-end=\"455\">dynamic and interactive web pages<\/strong>.<br data-start=\"456\" data-end=\"459\" \/>Unlike HTML, which only displays static content, PHP can <strong data-start=\"516\" data-end=\"532\">process data<\/strong>, <strong data-start=\"534\" data-end=\"561\">interact with databases<\/strong>, and <strong data-start=\"567\" data-end=\"603\">make websites work intelligently<\/strong>.<\/p>\n<h3 data-start=\"606\" data-end=\"633\"><strong data-start=\"610\" data-end=\"633\">Key Features of PHP<\/strong><\/h3>\n<ul data-start=\"634\" data-end=\"919\">\n<li data-start=\"634\" data-end=\"682\">\n<p data-start=\"636\" data-end=\"682\">Runs on a <strong data-start=\"646\" data-end=\"660\">web server<\/strong> (Apache, Nginx, IIS).<\/p>\n<\/li>\n<li data-start=\"683\" data-end=\"742\">\n<p data-start=\"685\" data-end=\"742\">Executes code <strong data-start=\"699\" data-end=\"709\">before<\/strong> the page is sent to the browser.<\/p>\n<\/li>\n<li data-start=\"743\" data-end=\"808\">\n<p data-start=\"745\" data-end=\"808\">Works smoothly with <strong data-start=\"765\" data-end=\"774\">MySQL<\/strong> for database-driven applications.<\/p>\n<\/li>\n<li data-start=\"809\" data-end=\"839\">\n<p data-start=\"811\" data-end=\"839\">Open-source and free to use.<\/p>\n<\/li>\n<li data-start=\"840\" data-end=\"919\">\n<p data-start=\"842\" data-end=\"919\">Widely used in CMS like <strong data-start=\"866\" data-end=\"914\">WordPress, Moodle, Facebook (early versions)<\/strong> etc.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"921\" data-end=\"924\" \/>\n<h2 data-start=\"926\" data-end=\"952\"><strong data-start=\"929\" data-end=\"952\">Where Does PHP Run?<\/strong><\/h2>\n<p data-start=\"953\" data-end=\"965\">PHP runs on:<\/p>\n<ul data-start=\"966\" data-end=\"1096\">\n<li data-start=\"966\" data-end=\"1008\">\n<p data-start=\"968\" data-end=\"1008\"><strong data-start=\"968\" data-end=\"983\">Server-side<\/strong>, not inside the browser.<\/p>\n<\/li>\n<li data-start=\"1009\" data-end=\"1096\">\n<p data-start=\"1011\" data-end=\"1096\">Requires a <strong data-start=\"1022\" data-end=\"1050\">local server environment<\/strong> like XAMPP\/WAMP or a real web hosting server.<\/p>\n<\/li>\n<\/ul>\n<p data-start=\"1098\" data-end=\"1211\">When you type <code data-start=\"1112\" data-end=\"1134\">localhost\/myfile.php<\/code>, the <strong data-start=\"1140\" data-end=\"1174\">server interprets the PHP code<\/strong> and sends the output to the browser.<\/p>\n<hr data-start=\"1213\" data-end=\"1216\" \/>\n<h2 data-start=\"1218\" data-end=\"1243\"><strong data-start=\"1221\" data-end=\"1243\">Common Uses of PHP<\/strong><\/h2>\n<p data-start=\"1244\" data-end=\"1477\">\u2714 Create <strong data-start=\"1253\" data-end=\"1274\">dynamic web pages<\/strong><br data-start=\"1274\" data-end=\"1277\" \/>\u2714 Handle <strong data-start=\"1286\" data-end=\"1300\">HTML forms<\/strong> (login, registration, contact forms)<br data-start=\"1337\" data-end=\"1340\" \/>\u2714 Build <strong data-start=\"1348\" data-end=\"1376\">database-driven websites<\/strong><br data-start=\"1376\" data-end=\"1379\" \/>\u2714 Manage <strong data-start=\"1388\" data-end=\"1412\">sessions and cookies<\/strong><br data-start=\"1412\" data-end=\"1415\" \/>\u2714 Develop <strong data-start=\"1425\" data-end=\"1447\">e-commerce systems<\/strong><br data-start=\"1447\" data-end=\"1450\" \/>\u2714 Create <strong data-start=\"1459\" data-end=\"1475\">API backends<\/strong><\/p>\n<hr data-start=\"1479\" data-end=\"1482\" \/>\n<h2 data-start=\"1484\" data-end=\"1520\"><strong data-start=\"1487\" data-end=\"1520\">Comparing PHP with JavaScript<\/strong><\/h2>\n<p data-start=\"1521\" data-end=\"1597\">You already know JavaScript from earlier classes. Here\u2019s a clear comparison:<\/p>\n<table>\n<thead data-start=\"1599\" data-end=\"1629\">\n<tr data-start=\"1599\" data-end=\"1629\">\n<th data-start=\"1599\" data-end=\"1609\" data-col-size=\"sm\">Feature<\/th>\n<th data-start=\"1609\" data-end=\"1615\" data-col-size=\"sm\">PHP<\/th>\n<th data-start=\"1615\" data-end=\"1629\" data-col-size=\"sm\">JavaScript<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<div>\n<table style=\"height: 38px;\" width=\"722\">\n<tbody>\n<tr data-start=\"1662\" data-end=\"1705\">\n<td data-start=\"1662\" data-end=\"1676\" data-col-size=\"sm\"><strong data-start=\"1664\" data-end=\"1675\">Runs on<\/strong><\/td>\n<td data-col-size=\"sm\" data-start=\"1676\" data-end=\"1685\">Server<\/td>\n<td data-col-size=\"sm\" data-start=\"1685\" data-end=\"1705\">Browser (client)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<table>\n<tbody>\n<tr data-start=\"1706\" data-end=\"1771\">\n<td data-start=\"1706\" data-end=\"1716\" data-col-size=\"sm\"><strong data-start=\"1708\" data-end=\"1715\">Use<\/strong><\/td>\n<td data-col-size=\"sm\" data-start=\"1716\" data-end=\"1742\">Backend logic, database<\/td>\n<td data-col-size=\"sm\" data-start=\"1742\" data-end=\"1771\">Validation, interactivity<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<table>\n<tbody>\n<tr data-start=\"1772\" data-end=\"1807\">\n<td data-start=\"1772\" data-end=\"1793\" data-col-size=\"sm\"><strong data-start=\"1774\" data-end=\"1792\">File extension<\/strong><\/td>\n<td data-col-size=\"sm\" data-start=\"1793\" data-end=\"1800\">.php<\/td>\n<td data-col-size=\"sm\" data-start=\"1800\" data-end=\"1807\">.js<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<table>\n<tbody>\n<tr data-start=\"1808\" data-end=\"1876\">\n<td data-start=\"1808\" data-end=\"1833\" data-col-size=\"sm\"><strong data-start=\"1810\" data-end=\"1832\">Who sees the code?<\/strong><\/td>\n<td data-col-size=\"sm\" data-start=\"1833\" data-end=\"1856\">Hidden (server only)<\/td>\n<td data-col-size=\"sm\" data-start=\"1856\" data-end=\"1876\">Visible to users<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2 data-start=\"2017\" data-end=\"2038\"><strong data-start=\"2020\" data-end=\"2038\">Simple Example<\/strong><\/h2>\n<div class=\"contain-inline-size rounded-2xl corner-superellipse\/1.1 relative bg-token-sidebar-surface-primary\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"whitespace-pre! language-php\"><span class=\"hljs-meta\">&lt;?php<\/span><br \/>\n<span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"Hello from PHP!\"<\/span>;<br \/>\n<span class=\"hljs-meta\">?&gt;<\/span><br \/>\n<\/code><\/div>\n<\/div>\n<p data-start=\"2084\" data-end=\"2137\">When run on a server, it outputs: <strong data-start=\"2118\" data-end=\"2137\">Hello from PHP!<\/strong><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is PHP? PHP (Hypertext Preprocessor) is a server-side scripting language used to create dynamic and interactive web pages.Unlike HTML, which only displays static content, PHP can process data, interact with databases, and make websites work intelligently. Key Features of PHP Runs on a web server (Apache, Nginx, IIS). Executes code before the page is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5646,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1066,1070,1080,1071],"tags":[],"class_list":["post-5645","post","type-post","status-publish","format-standard","has-post-thumbnail","category-latest-news","category-learning-resources","category-php-courses","category-tutorials-guides"],"_links":{"self":[{"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=\/wp\/v2\/posts\/5645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5645"}],"version-history":[{"count":2,"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=\/wp\/v2\/posts\/5645\/revisions"}],"predecessor-version":[{"id":5648,"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=\/wp\/v2\/posts\/5645\/revisions\/5648"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=\/wp\/v2\/media\/5646"}],"wp:attachment":[{"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.eastlink.com.np\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}