[{"data":1,"prerenderedAt":327},["ShallowReactive",2],{"blog-php":3},{"id":4,"title":5,"body":6,"date":313,"description":314,"draft":315,"extension":316,"image":317,"meta":318,"navigation":319,"path":320,"seo":321,"stem":322,"tags":323,"__hash__":326},"blogs\u002Fblogs\u002Fphp\u002Findex.md","PHP a general purpose programming language",{"type":7,"value":8,"toc":306},"minimark",[9,13,18,28,31,34,38,41,50,54,61,64,67,102,114,117,227,231,234,251,254,259,275,278,283,295,299,302],[10,11,12],"p",{},"Programming languages are formal systems designed for expressing computations. They are used to instruct computers and create software applications. There are numerous programming languages, each with its own syntax, semantics, and purposes.",[14,15,17],"h3",{"id":16},"types-of-programming-languages","Types of programming languages",[19,20,21,25],"ol",{},[22,23,24],"li",{},"Domain specific like SQL",[22,26,27],{},"General purpose like C++, Java, Python, PHP.",[10,29,30],{},"The domain-specific languages are used within specific application domains. For example, SQL is a domain-specific language. It’s used mainly for querying data from relational databases. And SQL cannot be used for other purposes.",[10,32,33],{},"On the other hand, PHP is a general-purpose language because PHP can develop various applications but it is mainly used in web development.",[14,35,37],{"id":36},"what-can-php-do","What can PHP do ?",[10,39,40],{},"PHP has two main applications :",[42,43,44,47],"ul",{},[22,45,46],{},"Server side scripting - developing dynamic websites",[22,48,49],{},"Command line scripting - like python, we can run PHP script from command line to send mails or some admin tasks.",[14,51,53],{"id":52},"how-php-works","How PHP works ?",[10,55,56],{},[57,58],"img",{"alt":59,"src":60},"How PHP works image","\u002Fimages\u002Fblogs\u002Fphp\u002FWhat-is-PHP-How-PHP-works.png",[10,62,63],{},"To Work with PHP we need to have following software installed",[10,65,66],{},"PHP",[42,68,69,79,86,94],{},[22,70,71,78],{},[72,73,77],"a",{"href":74,"rel":75},"https:\u002F\u002Fwww.apache.org\u002F",[76],"nofollow","Apache"," ( Web server )",[22,80,81,85],{},[72,82,66],{"href":83,"rel":84},"https:\u002F\u002Fwww.php.net\u002Fdownloads.php",[76]," ( Zend Engine )",[22,87,88,93],{},[72,89,92],{"href":90,"rel":91},"https:\u002F\u002Fpecl.php.net",[76],"PECL"," ( PHP Extension manager )",[22,95,96,101],{},[72,97,100],{"href":98,"rel":99},"https:\u002F\u002Fgetcomposer.org",[76],"Composer"," ( PHP Library manager )",[10,103,104,108,109],{},[105,106,107],"strong",{},"Note:"," To get started you can also try ",[72,110,113],{"href":111,"rel":112},"https:\u002F\u002Ffrankenphp.dev\u002F",[76],"FrankenPHP",[10,115,116],{},"After installation you will see something like this in your terminal",[118,119,124],"pre",{"className":120,"code":121,"language":122,"meta":123,"style":123},"language-bash shiki shiki-themes github-light","govind@debian:~$ php -v\nPHP 8.3.11 (cli) (built: Sep  2 2024 15:06:27) (NTS)\nCopyright (c) The PHP Group\nZend Engine v4.3.11, Copyright (c) Zend Technologies\n    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies\n","bash","",[125,126,127,144,180,189,207],"code",{"__ignoreMap":123},[128,129,132,136,140],"span",{"class":130,"line":131},"line",1,[128,133,135],{"class":134},"s7eDp","govind@debian:~$",[128,137,139],{"class":138},"sYBdl"," php",[128,141,143],{"class":142},"sYu0t"," -v\n",[128,145,147,149,152,156,159,162,165,168,171,174,177],{"class":130,"line":146},2,[128,148,66],{"class":134},[128,150,151],{"class":142}," 8.3.11",[128,153,155],{"class":154},"sgsFI"," (cli) (",[128,157,158],{"class":134},"built:",[128,160,161],{"class":138}," Sep",[128,163,164],{"class":142},"  2",[128,166,167],{"class":142}," 2024",[128,169,170],{"class":138}," 15:06:27",[128,172,173],{"class":154},") (",[128,175,176],{"class":134},"NTS",[128,178,179],{"class":154},")\n",[128,181,183,186],{"class":130,"line":182},3,[128,184,185],{"class":134},"Copyright",[128,187,188],{"class":154}," (c) The PHP Group\n",[128,190,192,195,198,201,204],{"class":130,"line":191},4,[128,193,194],{"class":134},"Zend",[128,196,197],{"class":138}," Engine",[128,199,200],{"class":138}," v4.3.11,",[128,202,203],{"class":138}," Copyright",[128,205,206],{"class":154}," (c) Zend Technologies\n",[128,208,210,213,216,219,222,224],{"class":130,"line":209},5,[128,211,212],{"class":134},"    with",[128,214,215],{"class":138}," Zend",[128,217,218],{"class":138}," OPcache",[128,220,221],{"class":138}," v8.3.11,",[128,223,203],{"class":138},[128,225,226],{"class":154}," (c), by Zend Technologies\n",[14,228,230],{"id":229},"running-php-code","Running PHP code",[10,232,233],{},"First of all make a file named index.php and write some code in it as given below",[118,235,239],{"className":236,"code":237,"language":238,"meta":123,"style":123},"language-php shiki shiki-themes github-light","\u003C?php\n    echo \"Hello world\";\n","php",[125,240,241,246],{"__ignoreMap":123},[128,242,243],{"class":130,"line":131},[128,244,245],{},"\u003C?php\n",[128,247,248],{"class":130,"line":146},[128,249,250],{},"    echo \"Hello world\";\n",[10,252,253],{},"There is 2 ways by which you can run PHP code",[42,255,256],{},[22,257,258],{},"Serve on the web",[118,260,262],{"className":120,"code":261,"language":122,"meta":123,"style":123},"  php -S localhost:8000\n",[125,263,264],{"__ignoreMap":123},[128,265,266,269,272],{"class":130,"line":131},[128,267,268],{"class":134},"  php",[128,270,271],{"class":142}," -S",[128,273,274],{"class":138}," localhost:8000\n",[10,276,277],{},"now go to the browser and type localhost:8000 in address bar",[42,279,280],{},[22,281,282],{},"On the Command line",[118,284,286],{"className":120,"code":285,"language":122,"meta":123,"style":123},"  php index.php\n",[125,287,288],{"__ignoreMap":123},[128,289,290,292],{"class":130,"line":131},[128,291,268],{"class":134},[128,293,294],{"class":138}," index.php\n",[14,296,298],{"id":297},"conclusion","Conclusion",[10,300,301],{},"PHP continues to be a powerful and versatile language for both web and command-line applications. Its ability to dynamically generate content, combined with an extensive ecosystem of libraries and frameworks, makes it a popular choice for developers worldwide.",[303,304,305],"style",{},"html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":123,"searchDepth":146,"depth":146,"links":307},[308,309,310,311,312],{"id":16,"depth":182,"text":17},{"id":36,"depth":182,"text":37},{"id":52,"depth":182,"text":53},{"id":229,"depth":182,"text":230},{"id":297,"depth":182,"text":298},"2023-11-11","Choosing a programming language often depends on the task at hand, the platform you are targeting, and your personal preferences.",false,"md",null,{},true,"\u002Fblogs\u002Fphp",{"title":5,"description":314},"blogs\u002Fphp\u002Findex",[238,324,325],"programming language","computer science","rZF_k9qJFNfo7T8MbXtXWnk8xDShS2xtiRJk_uxN0xE",1782753863855]