Chapterبەش 5 · Lectureوانە 5.1
Introduction to PHPسەرەتایەک بۆ PHP
What PHP is, where it came from, why so many websites use it, and how a PHP page becomes the HTML that the browser shows.
PHP چییە، لە کوێوە هاتووە، بۆچی ئەم هەموو بەکاری دەهێنن و چۆن لاپەڕەیەکی PHP دەبێت بەو HTMLـەی پیشانی دەدات.
What you will learnچی فێر دەبیت
- Explain what PHP is and what its name means.
- Tell the difference between static and dynamic web pages.
- Explain what server-side means and compare PHP with JavaScript.
- Describe how a .php file that mixes HTML and PHP becomes plain HTML in the browser.
- List the main features of PHP and the jobs it can do.
- ڕوون بکەیتەوە PHP چییە و ناوەکەی واتای چییە.
- جیاوازیی نێوان و بڵێیت.
- ڕوون بکەیتەوە واتای چییە و PHP لەگەڵ JavaScript بەراورد بکەیت.
- باسی ئەوە بکەیت کە چۆن .php کە HTML و PHP تێکەڵ دەکات دەبێت بە HTMLـی ئاسایی لە .
- تایبەتمەندییە سەرەکییەکانی PHP و ئەو کارانەی دەتوانێت بیکات ڕیز بکەیت.
Why learn PHP?بۆچی PHP فێر ببین؟
You already know that describes a : its headings, paragraphs, links and forms. But an HTML file is fixed. It shows the same words to every visitor, and it cannot remember anything, check a password or save a message.
پێشتر زانیت کە وەسف دەکات: سەردێڕ، بڕگە، و . بەڵام HTML جێگیرە. هەمان وشە بۆ هەموو سەردانیکەرێک پیشان دەدات و ناتوانێت هیچ شتێک لەبیر بێت، بپشکنێت یان نامەیەک پاشەکەوت بکات.
fills this gap. It is a language that runs on the and builds the HTML for each visitor. With PHP a page can greet you by name, show today's date, read a and react to what you type in a .
ئەم کەلێنە پڕ دەکاتەوە. زمانێکە کە لەسەر کار دەکات و بۆ هەر سەردانیکەرێک HTMLـەکە دروست دەکات. بە PHP لاپەڕەیەک دەتوانێت بە ناوی خۆتەوە سڵاوت لێ بکات، بەرواری ئەمڕۆ پیشان بدات، بخوێنێتەوە و کاردانەوەی هەبێت بەرامبەر ئەوەی لە دەینووسیت.
What you will learn
چی فێر دەبیت
- What PHP is, and what its name means.
- Who made PHP and how it grew.
- The difference between static and dynamic web pages.
- What “server-side” means, and how PHP differs from JavaScript.
- How PHP and HTML work together, and what the browser finally receives.
- Why so many developers choose PHP, and what PHP can do.
- PHP چییە و ناوەکەی واتای چییە.
- کێ PHPـی دروست کرد و چۆن گەشەی کرد.
- جیاوازیی نێوان و .
- «» واتای چییە و PHP چ جیاوازییەکی لەگەڵ JavaScript هەیە.
- PHP و HTML چۆن پێکەوە کار دەکەن و لە کۆتاییدا چی دەگاتە .
- بۆچی ئەم هەموو گەشەپێدەرە PHP هەڵدەبژێرن و PHP چی دەتوانێت بکات.
Why learn PHP?بۆچی PHP فێر ببین؟
How popular is PHP?PHP چەندە بەکار دێت؟
PHP is one of the most used languages on the web. The survey site W3Techs reported in October 2026 that PHP is used by 69.4% of all websites whose language it can detect. Big sites such as Wikipedia and WordPress are written in PHP.
PHP یەکێکە لە بەکارهاتووترین زمانەکانی وێب. ماڵپەڕی ئاماری W3Techs لە مانگی تشرینی یەکەمی 2026دا ڕایگەیاند کە 69.4%ی ئەو تۆڕگانەی کە زمانی دیارە PHP بەکار دەهێنن. گەورەکانی وەک Wikipedia و WordPress بە PHP نووسراون.
What is PHP?PHP چییە؟
A free, for making dynamic web pages. PHP code runs on the ; the visitor's browser receives only the result, usually HTML.
PHP بریتییە لە کە بەخۆڕایی بەکار دەهێنرێت و بۆ دروستکردنی دانراوە. کۆدەکەی لەسەر جێبەجێ دەکرێت و تەنها ئەنجامەکەی، کە زۆرجار HTMLـە، دەگاتە .
Here are the main facts about PHP, collected from the lectures, the slides and the course notes:
ئەمانە ڕاستییە سەرەکییەکانن دەربارەی PHP، کە لە وانەکان، سلایدەکان و تێبینییەکانی کۆرسەکەوە کۆکراونەتەوە:
- PHP is a . Its code runs on the , not in the visitor's browser.
- With PHP we can build dynamic websites: pages whose content changes.
- PHP runs entirely on the server, so the visitor's computer needs no special features. Any browser can open a PHP page.
- PHP is and free. You can download it from the official site, php.net.
- PHP is : it runs on Windows, Linux, Unix and macOS.
- Its is based on the languages , Java and C. If you have seen C, Java or JavaScript, PHP will look familiar from the first line.
- It has a very large of ready-made that programmers can use, for example for dates, files, images and PDF documents.
- It is a : it is close to English, so people can read it easily. The Kurdish notes call it “human-friendly” (مرۆڤدۆست).
- It is easy to learn and runs efficiently on the server.
- PHP . کۆدەکەی لەسەر جێبەجێ دەکرێت، نەک لەناو سەردانیکەردا.
- بە PHP دەتوانین داینامیک دروست بکەین: لاپەڕەگەلێک کە ناوەڕۆکەکەیان دەگۆڕێت.
- PHP بە تەواوی لەسەر کار دەکات، بۆیە سەردانیکەر پێویستی بە هیچ تایبەتمەندییەکی تایبەت نییە. هەر دەتوانێت لاپەڕەیەکی PHP بکاتەوە.
- PHP و بەخۆڕاییە. دەتوانیت لە ماڵپەڕە فەرمییەکەیەوە، php.net، دایبگریت.
- PHP : لەسەر Windows و Linux و Unix و macOS کار دەکات.
- PHP لەسەر بنەمای زمانەکانی و Java و C دانراوە. ئەگەر C یان Java یان JavaScriptـت بینیبێت، PHP هەر لە یەکەم دێڕەوە ئاشنا دەبێت.
- زۆر گەورەی هەیە کە دەتوانن بەکاریان بهێنن، بۆ نموونە بۆ بەروار، ، وێنە و بەڵگەنامەی PDF.
- PHP : لە ئینگلیزییەوە نزیکە، بۆیە مرۆڤ بە ئاسانی دەیخوێنێتەوە. تێبینییە کوردییەکان پێی دەڵێن «مرۆڤدۆست» (Human-friendly).
- فێربوونی ئاسانە و لەسەر بە باشی و خێرایی کار دەکات.
What is PHP?PHP چییە؟
What does “PHP” stand for?«PHP» کورتکراوەی چییە؟
Today PHP stands for PHP: Hypertext Preprocessor. The first P of “PHP” is “PHP” again! A name that contains itself like this is called a recursive acronym.
ئەمڕۆ PHP PHP: Hypertext Preprocessorـە. یەکەم P لە «PHP»دا دیسان «PHP»ـە! ناوێک کە بەم شێوەیە خۆی لەخۆ بگرێت پێی دەگوترێت بازنەیی (recursive acronym).
- Hypertext means text with links: the HTML of web pages.
- Preprocessor means “it works on the page before it is sent”. PHP prepares the HTML on the server, then the server sends it.
- At first the name meant Personal Home Page, because PHP began as a small tool for one person's home page.
- Hypertext واتە دەقی بەستەردار: هەمان HTMLـی .
- Preprocessor واتە «پێش ناردنی لاپەڕەکە کاری لەسەر دەکات». PHP لەسەر HTMLـەکە ئامادە دەکات، پاشان دەینێرێت.
- لە سەرەتادا ناوەکە واتای Personal Home Page (پەڕەی سەرەکیی کەسی) بوو، چونکە PHP وەک ئامرازێکی بچووک بۆ پەڕەی کەسێک دەستی پێکرد.
What is PHP?PHP چییە؟
Server-side and client-side languagesزمانی ڕاژەبەند و زمانی لای ڕاژەخواز
Two computers take part when you open a web page: the (your computer with its ) and the (the computer that keeps the website). A language is when its code runs on the server, and when its code runs inside the browser.
کاتێک دەکەیتەوە دوو بەشدارن: ( خۆت لەگەڵ ) و (ئەو تێدایە). زمانێک ئەگەر کۆدەکەی لەسەر جێبەجێ بکرێت و ئەگەر کۆدەکەی لەناو جێبەجێ بکرێت.
| Questionپرسیار | PHP | JavaScript (in the browser)JavaScript (لە ) |
|---|---|---|
| Where does the code run?کۆدەکە لە کوێ جێبەجێ دەکرێت؟ | On the web server.لەسەر . | In the visitor's browser, on their own computer.لەناو سەردانیکەر، لەسەر خۆی. |
| Can the visitor read the code?سەردانیکەر دەتوانێت کۆدەکە بخوێنێتەوە؟ | No. Only the result (HTML) is sent.نەخێر. تەنها ئەنجامەکە (HTML) دەنێردرێت. | Yes. The code is sent to the browser.بەڵێ. کۆدەکە بۆ دەنێردرێت. |
| Typical jobsکارە باوەکان | Read and save data, check passwords, build pages.خوێندنەوە و پاشەکەوتکردنی ، پشکنینی ، دروستکردنی لاپەڕە. | Menus, animations, checking a form before it is sent.مێنیو، جووڵە، پشکنینی پێش ناردنی. |
Think of a restaurant in the bazaar. You (the browser) order a dish. The cook in the kitchen (the server) follows a recipe (the PHP code) and prepares the food. The waiter brings you only the finished dish (the HTML). You eat it, but you never see the recipe. Adding salt at your own table is like JavaScript: it happens on your side, after the food arrives.
چێشتخانەیەک لە بازاڕدا بهێنە بەرچاوت. تۆ () داوای خواردنێک دەکەیت. چێشتلێنەرەکە لە چێشتخانەکەدا () بەپێی ڕێچکەیەک (کۆدی PHP) خواردنەکە ئامادە دەکات. گارسۆنەکە تەنها خواردنە ئامادەکراوەکەت بۆ دەهێنێت (HTML). دەیخۆیت، بەڵام هەرگیز ڕێچکەکە نابینیت. خوێ تێکردن لەسەر مێزەکەی خۆت وەک JavaScript وایە: لای خۆت ڕوودەدات، دوای ئەوەی خواردنەکە گەیشت.
Where the analogy stops workingسنووری ئەم نموونەیە
A real cook makes each dish by hand. A web server can build thousands of pages per second, and it builds a fresh page for every request.
چێشتلێنەری ڕاستەقینە هەر خواردنێک بە دەست دروست دەکات. دەتوانێت لە چرکەیەکدا هەزاران لاپەڕە دروست بکات و بۆ هەر لاپەڕەیەکی نوێ دروست دەکات.
Explains the client and the server computers, why HTML, CSS and JavaScript run in the browser while PHP runs on the server, and front end vs back end.
و ڕوون دەکاتەوە، بۆچی ، و لە کار دەکەن بەڵام لەسەر کار دەکات، هەروەها جیاوازیی و .
Watch 0:42 to 9:03: client vs server computers and languages
لە 0:42 تا 9:03 سەیر بکە: و و ئەو زمانانەی لەسەر هەریەکەیان کار دەکەن.
A short history of PHPکورتە مێژوویەکی PHP
PHP was created by the programmer Rasmus Lerdorf. He was born in Greenland and is Danish-Canadian (the Kurdish notes call him a Danish programmer). In 1994 he wrote a small set of tools to count the visitors to his own website (his online CV). He called them “Personal Home Page Tools”.
PHP لەلایەن بە ناوی ڕاسمۆس لێردۆرف (Rasmus Lerdorf) دروست کرا. لە گرینلاند لەدایک بووە و دانیمارکی-کەنەدییە (تێبینییە کوردییەکان پێی دەڵێن دانیمارکی). لە ساڵی 1994دا کۆمەڵە ئامرازێکی بچووکی نووسی بۆ ژماردنی سەردانیکەرانی خۆی (CVـە ئۆنلاینەکەی). ناوی نان «Personal Home Page Tools».
Later he added more features, for example connecting a website to a database. In June 1995 he made the source code public and open to everyone. This opened the way for other developers to improve it, and PHP grew quickly into a full language.
دواتر تایبەتمەندیی زیاتری بۆ زیاد کرد، بۆ نموونە بەستنەوەی بە . لە مانگی حوزەیرانی 1995دا کۆدەکەی بۆ هەمووان ئاشکرا و کراوە کرد. ئەمە ڕێگەی بۆ گەشەپێدەرانی تر خۆش کرد کە پەرەی پێ بدەن و PHP بە خێرایی بوو بە زمانێکی تەواو.
| Whenکەی | What happenedچی ڕوویدا |
|---|---|
| 1994 | Rasmus Lerdorf writes small tools, in the C language, to track visits to his online CV.ڕاسمۆس لێردۆرف بە زمانی C ئامرازی بچووک دەنووسێت بۆ بەدواداچوونی سەردانەکانی CVـە ئۆنلاینەکەی. |
| June 1995حوزەیرانی 1995 | He releases the source code of “PHP Tools” to the public. «PHP Tools» بۆ خەڵک بڵاو دەکاتەوە. |
| 1996–1997 | PHP/FI 2.0: PHP becomes more like a real programming language.PHP/FI 2.0: PHP زیاتر دەبێت بە ڕاستەقینە. |
| June 1998حوزەیرانی 1998 | PHP 3.0, rewritten by Andi Gutmans and Zeev Suraski. The name now means “PHP: Hypertext Preprocessor”.PHP 3.0، کە ئاندی گوتمانز و زێڤ سورەسکی لە نوێوە نووسییانەوە. ناوەکە ئێستا واتای «PHP: Hypertext Preprocessor»ـە. |
| May 2000ئایاری 2000 | PHP 4.0, with the new Zend Engine.PHP 4.0، لەگەڵ بزوێنەری نوێی Zend Engine. |
| July 2004تەمموزی 2004 | PHP 5.0, with much better object-oriented programming.PHP 5.0، لەگەڵ ئۆبجێکتیی زۆر باشتر. |
| December 2015کانوونی یەکەمی 2015 | PHP 7.0: much faster. Old features such as ASP-style tags are removed.PHP 7.0: زۆر خێراتر. تایبەتمەندیی کۆنی وەک شێوە-ASP لابران. |
| November 2020تشرینی دووەمی 2020 | PHP 8.0: many modern features and stricter error checking.PHP 8.0: زۆر تایبەتمەندیی نوێ و پشکنینی توندتری . |
| November 2025تشرینی دووەمی 2025 | PHP 8.5. Every example in this course was tested with PHP 8.5.PHP 8.5. هەموو نموونەکانی ئەم کۆرسە بە PHP 8.5 تاقی کراونەتەوە. |
In under a minute: what PHP is, where the name PHP comes from, and how Rasmus Lerdorf started it in 1994.
لە کەمتر لە یەک خولەکدا: چییە، ناوی لە کوێوە هاتووە و چۆن Rasmus Lerdorf لە ساڵی 1994دا دەستی پێکرد.
Watch 0:00 to 0:56: what PHP is and its history
لە 0:00 تا 0:56 سەیر بکە: چییە و مێژووەکەی.
Static and dynamic web pagesلاپەڕەتۆڕی نەگۆڕ و لاپەڕەتۆڕی داینامیک
Every website is made of web pages. There are two kinds:
هەموو لە پێکهاتووە. دوو جۆر هەیە:
- A has fixed content and a fixed structure. Every visitor sees the same thing, and visitors cannot change the content. Only the person who owns the file can change it, by editing the file.
- A is built or changed by a program, often for each visitor. Its structure and content change. Visitors interact with the site and change its content: on facebook.com, for example, users upload pictures, links and videos, write comments, post and send messages.
- ناوەڕۆک و پێکهاتەیەکی جێگیری هەیە. هەموو سەردانیکەرێک هەمان شت دەبینێت و سەردانیکەران ناتوانن ناوەڕۆکەکە بگۆڕن. تەنها خاوەنی دەتوانێت بیگۆڕێت، بە دەستکاریکردنی .
- دروستی دەکات یان دەیگۆڕێت، زۆرجار بۆ هەر سەردانیکەرێک. پێکهاتە و ناوەڕۆکەکەی دەگۆڕێن. سەردانیکەران مامەڵە لەگەڵ دەکەن و ناوەڕۆکەکەی دەگۆڕن: بۆ نموونە لە facebook.com وێنە، و ڤیدیۆ بار دەکەن، کۆمێنت دەنووسن، پۆست دەکەن و نامە دەنێرن.
A static website is like a printed book. Many people read it, but no reader can change it: it belongs, unchanged, to its author. A dynamic website is more like a notice board in a school corridor, where students pin their own notes and the board looks different every day.
وەک کتێبێکی چاپکراو وایە. خەڵکێکی زۆر دەیخوێننەوە، بەڵام هیچ خوێنەرێک ناتوانێت بیگۆڕێت، چونکە موڵکی نووسەرەکەیەتی و وەک خۆی دەمێنێتەوە. زیاتر وەک تەختەی ڕاگەیاندن وایە لە ڕاڕەوی قوتابخانەدا، کە قوتابیان تێبینیی خۆیانی پێوە دەلکێنن و هەموو ڕۆژێک شێوەیەکی جیاوازی هەیە.
Where the analogy stops workingسنووری ئەم نموونەیە
A book never changes after printing, but the owner of a static site can still edit the file and upload it again. “Static” only means the server sends the file as it is; the page may still contain JavaScript that moves things in the browser.
کتێب دوای چاپکردن هەرگیز ناگۆڕێت، بەڵام خاوەنی دەتوانێت دەستکاری بکات و دووبارە باری بکاتەوە. «» تەنها واتە وەک خۆی دەنێرێت؛ لەوانەیە لاپەڕەکە هێشتا JavaScriptـی تێدا بێت کە شتەکان لەناو دەجووڵێنێت.
Shows what a static page is and what a dynamic page is (built on the server for each request), and compares the two.
نیشان دەدات چییە و چییە (کە بۆ هەر دروستی دەکات)، پاشان هەردووکیان بەراورد دەکات.
Watch 0:23 to 5:56: static vs dynamic sites compared
لە 0:23 تا 5:56 سەیر بکە: بەراوردکردنی و .
Static and dynamic web pagesلاپەڕەتۆڕی نەگۆڕ و لاپەڕەتۆڕی داینامیک
Why dynamic websites were inventedبۆچی تۆڕگەی داینامیک دروست کرا
In the beginning, websites were static. Their makers only displayed information, and users could not change any of it. Later, people working on the web wanted more: websites that interact with users, so that people anywhere in the world can enter information and receive it. After all, one main purpose of the Internet is collecting useful information.
لە سەرەتادا جێگیر و نەگۆڕاو بوون. دروستکەرانیان تەنها زانیارییان پیشان دەدا و نەیاندەتوانی هیچی لێ بگۆڕن. دواتر ئەوانەی لە بواری وێبدا کاریان دەکرد زیاتریان ویست: کە مامەڵە لەگەڵ بکەن، تا خەڵک لە هەر شوێنێکی جیهاندا بتوانن زانیاری داخڵ بکەن و وەربگرن. لە کۆتاییدا، یەکێک لە مەبەستە سەرەکییەکانی کۆکردنەوەی زانیاریی بەسوودە.
So several languages were created to make websites dynamic, to take them out of the static state. PHP was one of the most successful of these languages. It developed fast and became famous.
بۆیە چەند زمانێک دروست کران بۆ ئەوەی داینامیک بکەن و لە دۆخی جێگیری دەریان بهێنن. PHP یەکێک بوو لە سەرکەوتووترینی ئەو زمانانە. بە خێرایی پێشکەوت و ناودار بوو.
Static and dynamic web pagesلاپەڕەتۆڕی نەگۆڕ و لاپەڕەتۆڕی داینامیک
A tiny dynamic pageلاپەڕەیەکی داینامیکی بچووک
This one line is already a dynamic page. PHP writes the current time into the HTML each time the page is requested. Reload the page and the time changes, although nobody edited the file.
ئەم یەک دێڕە خۆی لاپەڕەیەکی داینامیکە. هەر جارێک داوای لاپەڕەکە بکرێت، PHP کاتی ئێستا دەنووسێتە ناو HTMLـەکەوە. لاپەڕەکە نوێ بکەرەوە و کاتەکە دەگۆڕێت، هەرچەندە کەس دەستکاری نەکردووە.
<p>This page was made at <?php echo date("H:i:s"); ?>.</p>This page was made at 11:05:50.
HTML sent to the browserئەو HTMLـەی دەنێردرێت بۆ تۆڕگەڕ
<p>This page was made at 11:05:50.</p>The time shown is the moment we ran the example. Your time will be different.
ئەو کاتەی پیشان دراوە کاتی کارپێکردنی نموونەکەیە لای ئێمە. کاتەکەی تۆ جیاواز دەبێت.
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 1
date("H:i:s")gives the server's time as hours:minutes:seconds.echoputs it into the page. You will learnechoin Output with echo and print.date("H:i:s")کاتی بە شێوەی کاتژمێر:خولەک:چرکە دەدات.echoدەیخاتە ناو لاپەڕەکەوە.echoلە وانەی دەرخستە بە echo و print فێر دەبیت.
PHP works together with HTMLPHP و HTML پێکەوە کار دەکەن
PHP is designed to be used with HTML:
PHP بۆ ئەوە دروست کراوە کە لەگەڵ HTML بەکار بێت:
- PHP code can be embedded in HTML: you put small pieces of PHP between the HTML lines of a page. This is called .
- PHP returns HTML to the browser. The browser never receives PHP code.
- The PHP code is our input, and the web page is our output.
- PHP gives more flexibility than HTML alone. With HTML you can only make static pages; with PHP you can make dynamic pages too.
- کۆدی PHP دەتوانرێت لەناو HTMLـدا دابکوترێت: پارچەی بچووکی PHP دەخەیتە نێوان دێڕەکانی HTMLـی لاپەڕەیەکەوە. ئەمە پێی دەگوترێت .
- PHP HTML دەگەڕێنێتەوە بۆ . هەرگیز کۆدی PHP وەرناگرێت.
- کۆدی PHP نێوخستەی ئێمەیە و ئێمەیە.
- PHP نەرمییەکی زیاتر لە HTMLـی تەنها دەدات. بە HTML تەنها دەتوانیت دروست بکەیت؛ بە PHP دەتوانیت دروست بکەیت.
Because its code sits inside HTML pages, PHP is also called an embedded language (the Kurdish notes say «زمانێکی داکوتراو», a “nailed-in” language). Look at this small page. Most of it is ordinary HTML. Only the part between <?php and ?> is PHP.
لەبەر ئەوەی کۆدەکەی لەناو لاپەڕەکانی HTMLـدایە، بە PHP دەگوترێت زمانی داکوتراو (Embedded Language) (تێبینییە کوردییەکان دەڵێن «زمانێکی داکوتراو»). سەیری ئەم لاپەڕە بچووکە بکە. زۆربەی HTMLـی ئاساییە. تەنها ئەو بەشەی نێوان <?php و ?> PHPـە.
<!DOCTYPE html>
<html>
<head>
<title>Hana's Bookshop</title>
</head>
<body>
<h1>Hana's Bookshop</h1>
<p>Today is <?php echo date("l"); ?>.</p>
<p>Open from 9 to 5.</p>
</body>
</html>HTML sent to the browserئەو HTMLـەی دەنێردرێت بۆ تۆڕگەڕ
<!DOCTYPE html>
<html>
<head>
<title>Hana's Bookshop</title>
</head>
<body>
<h1>Hana's Bookshop</h1>
<p>Today is Friday.</p>
<p>Open from 9 to 5.</p>
</body>
</html>The browser receives this HTML. “Friday” was the day we ran the example; on another day PHP writes another name.
ئەم HTMLـە وەردەگرێت. «Friday» ئەو ڕۆژە بوو کە نموونەکەمان کار پێکرد؛ لە ڕۆژێکی تردا PHP ناوێکی تر دەنووسێت.
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 1-7
Plain HTML. PHP copies these lines to the output exactly as they are.
HTMLـی ئاسایی. PHP ئەم دێڕانە وەک خۆیان دەنووسێتەوە بۆ .
- Lineدێڕی 8
The only PHP code.
<?phpopens PHP,?>closes it.date("l")gives the name of today's day, andechowrites it into the page.تاکە کۆدی PHP.
<?phpPHP دەکاتەوە و?>دایدەخات.date("l")ناوی ڕۆژی ئەمڕۆ دەدات وechoدەینووسێتە ناو لاپەڕەکەوە.- Lineدێڕی 9-11
Plain HTML again.
دیسان HTMLـی ئاسایی.
<head> part of page.php.)چۆن .php کە HTML و PHP تێکەڵ دەکات دەبێت بەو HTMLـە ئاساییەی وەریدەگرێت. (وێنەکە بەشی <head>ی page.php پیشان نادات.)CêITWhy use PHP? Its main featuresبۆچی PHP بەکار بهێنین؟ تایبەتمەندییە سەرەکییەکانی
Why is PHP so popular? The lectures, the slides (“six reasons it is still everywhere”) and the Kurdish notes give these reasons:
بۆچی PHP ئەوەندە ناودارە؟ وانەکان، سلایدەکان («شەش هۆکار کە هێشتا لە هەموو شوێنێکە») و تێبینییە کوردییەکان ئەم هۆکارانە دەدەن:
| Reasonهۆکار | What it meansواتاکەی |
|---|---|
| Runs on many platformsلەسەر زۆر سیستەم کار دەکات | PHP is . It runs on many : Windows, Linux, Unix and macOS (the slides use its old name, Mac OS X).PHP . لەسەر زۆر کار دەکات: Windows و Linux و Unix و macOS (سلایدەکان ناوە کۆنەکەی بەکار دەهێنن، Mac OS X). |
| Works with almost every web serverلەگەڵ نزیکەی هەموو کار دەکات | , , Nginx, Caddy, Abyss Web Server and others.، ، Nginx، Caddy، Abyss Web Server و هی تر. |
| Supports many databasesپشتگیریی زۆر دەکات | , Oracle, Microsoft SQL Server, , PostgreSQL and more. See PHP and databases.، Oracle، Microsoft SQL Server، ، PostgreSQL و زیاتر. بڕوانە PHP و بنکەدراوە. |
| Freeبەخۆڕایی | There is nothing to buy. Download it from php.net.هیچ شتێک ناکڕیت. لە php.net دایبگرە. |
| Open source | Its own code is open. Programmers may study it and change it, for example to add new features.کۆدی خودی زمانەکە کراوەیە. دەتوانن بیخوێننەوە و بیگۆڕن، بۆ نموونە بۆ دانانی تایبەتمەندیی نوێ. |
| Easy to learnفێربوونی ئاسانە | Its syntax is short and easy to understand and use. PHP code can even be written right inside an HTML page. کورت و پوختە و تێگەیشتن و بەکارهێنانی ئاسانە. تەنانەت دەکرێت کۆدی PHP ڕاستەوخۆ لەناو لاپەڕەیەکی HTMLـدا بنووسرێت. |
| Fastخێرا | Pages are built quickly on the server, so they reach the visitor's screen fast. (The Kurdish notes give a different reason, that PHP is tied to HTML; see the correction below.)لاپەڕەکان بە خێرایی لەسەر دروست دەکرێن، بۆیە زوو دەگەنە سەر سەردانیکەر. (تێبینییە کوردییەکان هۆکارێکی تر دەدەن، ئەوەی کە PHP بە HTMLـەوە بەستراوەتەوە؛ بڕوانە ڕاستکردنەوەکەی خوارەوە.) |
| Powerful library support بەهێز | You can easily find ready-made modules for what you need, such as making PDF files or drawing graphs.بە ئاسانی مۆدیوڵی ئامادە بۆ ئەوەی پێویستتە دەدۆزیتەوە، وەک دروستکردنی PDF یان کێشانی . |
| Large community and helpکۆمەڵگەی گەورە و یارمەتی | Many websites, forums and the php.net manual help developers solve their problems.زۆر ، فۆرەم و ڕێنمایی php.net یارمەتی گەشەپێدەران دەدەن بۆ چارەسەرکردنی کێشەکانیان. |
| Object-oriented | Besides plain functions, PHP supports : and , , visibility (public, private, protected), , and destructors (__construct(), __destruct()). This course does not teach it; it is a good next step after the course.جگە لە سادە، PHP پشتگیریی دەکات: و ، ، public، private و protected، ، و destructor (__construct()، __destruct()). ئەم کۆرسە فێری ناکات؛ هەنگاوێکی باشە بۆ دوای کۆرسەکە. |
| Good characteristicsخاسیەتی باش | Simplicity, security (but read the correction below), flexibility, familiarity (it looks like C, Java and JavaScript) and efficiency on the server.سادەیی، (بەڵام ڕاستکردنەوەکەی خوارەوە بخوێنەوە)، نەرمی، ئاشنایی (لە C و Java و JavaScript دەچێت) و کارایی لەسەر . |
The Kurdish notes explain versatility with the word «گەڕۆک», a wanderer: a person who travels and is seen in many places. PHP is a wanderer too. The same PHP file can travel from your Windows laptop to a Linux server and keep working.
تێبینییە کوردییەکان گەڕۆکی (Versatility) بە وشەی «گەڕۆک» ڕوون دەکەنەوە: کەسێک کە گەشت دەکات و لە زۆر شوێندا دەبینرێت. PHPـیش گەڕۆکە. هەمان PHP دەتوانێت لە لاپتۆپە Windowsـەکەتەوە بڕوات بۆ Linux و هەر کار بکات.
Where the analogy stops workingسنووری ئەم نموونەیە
A wanderer needs nothing, but PHP must be installed on every computer that runs it, and some settings (such as file paths) differ between systems.
گەڕۆک پێویستی بە هیچ نییە، بەڵام PHP دەبێت لەسەر هەر کە کاری پێدەکات دابمەزرێت و هەندێک (وەک ) لە سیستەمێکەوە بۆ سیستەمێکی تر جیاوازن.
What can PHP do?PHP چی دەتوانێت بکات؟
PHP can do almost everything a website needs on the server side. The slides, the lectures and the Kurdish notes list these jobs:
PHP دەتوانێت نزیکەی هەموو ئەو شتانە بکات کە لەلای پێویستی پێیەتی. سلاید، وانە و تێبینییە کوردییەکان ئەم کارانە ناو دەبەن:
- Generate dynamic page content, for example a greeting with the visitor's name.
- Work with HTML forms: read what the user typed and answer it. (See Form handling.)
- Talk to many kinds of databases: add, read, change and delete data.
- Protect pages: show a page only to users who give the right username and password (a system).
- Encrypt data, and protect passwords with .
- Work with files on the server: create, open, read, write, delete and close files.
- Use and to remember visitors from one page to the next.
- Talk to the through commands.
- دروستکردنی ناوەڕۆکی داینامیک بۆ لاپەڕە، بۆ نموونە سڵاوێک بە ناوی سەردانیکەرەوە.
- مامەڵەکردن لەگەڵ HTML: خوێندنەوەی ئەوەی نووسیویەتی و وەڵامدانەوەی. (بڕوانە مامەڵەکردن لەگەڵ فۆرم.)
- گفتوگۆکردن لەگەڵ زۆر جۆری : تۆمارکردن، خوێندنەوە، گۆڕین و سڕینەوەی .
- پاراستنی لاپەڕەکان: لاپەڕەیەک تەنها بۆ ئەو پیشان بدرێت کە و دروست دەدەن (سیستەمی ).
- و پاراستنی بە .
- مامەڵەکردن لەگەڵ سەر : دروستکردن، کردنەوە، خوێندنەوە، نووسین، سڕینەوە و داخستنی .
- بەکارهێنانی و بۆ ئەوەی سەردانیکەران لە لاپەڕەیەکەوە بۆ لاپەڕەیەکی تر لەبیر بمێنن.
- گفتوگۆکردن لەگەڵ لە ڕێگەی فەرمانەکانەوە.
The Kurdish notes name three main jobs of PHP: working with HTML forms, talking to many kinds of databases, and protecting the content of pages with a username and an authorised password. They add two more abilities: working with the files of your system, and talking to the operating system. The next two parts look at them closely.
تێبینییە کوردییەکان سێ کاری سەرەکیی PHP ناو دەبەن: مامەڵەکردن لەگەڵ HTML، گفتوگۆکردن لەگەڵ زۆر جۆری و پاراستنی ناوەڕۆکی لاپەڕەکان بە و ڕێگەپێدراو. دوو توانای تریش زیاد دەکەن: مامەڵەکردن لەگەڵ سیستەمەکەت و گفتوگۆکردن لەگەڵ . دوو بەشی داهاتوو بە وردی سەیریان دەکەن.
What can PHP do?PHP چی دەتوانێت بکات؟
Files, folders and the operating systemفایل، فۆڵدەر و سیستەمی وەگەڕخەر
PHP can work with the : it can create, edit and delete and files on the server's hard disk, or on another computer of a . Why would a website need this? Some websites keep information in a file for a while, for example a list of visitors, a photo that a user uploaded, or a saved copy of a slow page.
PHP دەتوانێت لەگەڵ کار بکات: دەتوانێت و لەسەر ، یان لەسەر تری سەر ، دروست بکات، دەستکاری بکات و بیانسڕێتەوە. بۆچی پێویستی بەمە دەبێت؟ هەندێک زانیاری بۆ ماوەیەک لە هەڵدەگرن، بۆ نموونە لیستی سەردانیکەران، وێنەیەک کە باری کردووە، یان کۆپییەکی پاشەکەوتکراوی لاپەڕەیەکی خاو.
PHP can also talk to the through commands. The Kurdish notes give an example: run the dir command (Windows) or the ls command (Linux) from PHP to list the file names in a folder.
PHP دەتوانێت لە ڕێگەی فەرمانەکانەوە لەگەڵ گفتوگۆ بکات. تێبینییە کوردییەکان نموونەیەک دەدەن: فەرمانی dir (لە Windows) یان فەرمانی ls (لە Linux) لەناو PHPـەوە کار پێبکە بۆ ئەوەی ناوی ناو پیشان بدرێت.
What can PHP do?PHP چی دەتوانێت بکات؟
PHP and databasesPHP و بنکەدراوە
PHP can work and “talk” with a . You may ask: why a database? One answer from the Kurdish notes: to store the usernames and passwords for a login page. Every forum, shop and student portal keeps its data in a database.
PHP دەتوانێت لەگەڵ کار و «گفتوگۆ» بکات. لەوانەیە بپرسیت: بۆچی ؟ تێبینییە کوردییەکان ئەم نموونەیە دەدەن: بۆ هەڵگرتنی و بۆ لاپەڕەی . هەموو فۆرەم، دوکان و پۆرتاڵێکی خوێندکاران لە هەڵدەگرێت.
The Kurdish notes (from the book PHP for Dummies) list the databases that PHP supports: dBASE, Informix, Ingres, MS SQL Server, mSQL, MySQL, Oracle, PostgreSQL, Sybase, filePro, FrontBase and InterBase. The slides add SQLite. The list is old, so here it is with today's situation:
تێبینییە کوردییەکان (لە کتێبی PHP for Dummiesـەوە) ئەو بنکەدراوانە ناو دەبەن کە PHP پشتگیرییان دەکات: dBASE، Informix، Ingres، MS SQL Server، mSQL، MySQL، Oracle، PostgreSQL، Sybase، filePro، FrontBase و InterBase. سلایدەکان SQLiteـیش زیاد دەکەن. لیستەکە کۆنە، بۆیە لێرەدا لەگەڵ دۆخی ئەمڕۆدا دەیخەینە ڕوو:
| Groupکۆمەڵ | Databases |
|---|---|
| Very common with PHP todayئەمڕۆ زۆر باون لەگەڵ PHP | MySQL / MariaDB, PostgreSQL, SQLite |
| Also used with PHP todayئەمڕۆش لەگەڵ PHP بەکار دێن | Oracle, Microsoft SQL Server |
| Older systems from the book's list, rarely used with PHP todayسیستەمی کۆنی لیستی کتێبەکە، ئەمڕۆ کەم لەگەڵ PHP بەکار دێن | dBASE, Informix, Ingres, mSQL, Sybase, filePro, FrontBase, InterBase |
PHP also supports a standard called ODBC, short for Open Database Connectivity. ODBC lets PHP talk to even more databases, such as Microsoft Access and IBM Db2, using (Structured Query Language, «زمانی پرسگەلی ڕێکخراو» in the Kurdish notes).
PHP پشتگیریی پێوەرێکیش دەکات بە ناوی ODBC، کە Open Database Connectivityـە. ODBC ڕێگە بە PHP دەدات لەگەڵ زیاتریشدا گفتوگۆ بکات، وەک Microsoft Access و IBM Db2، لە ڕێگەی (Structured Query Language، کە تێبینییە کوردییەکان پێی دەڵێن «زمانی پرسگەلی ڕێکخراو»).
Practiceڕاهێنان
Decide whether each page is static or dynamic, and say why: (a) a college “About us” page that is the same for everyone; (b) an online shop's shopping cart; (c) a weather page that shows today's temperature in Erbil; (d) a page that shows a fixed photo of the Citadel; (e) the page that shows your exam results after you log in.
بڕیار بدە هەر لاپەڕەیەک یان داینامیک و بڵێ بۆچی: (أ) لاپەڕەی «دەربارەی ئێمە»ی کۆلێژێک کە بۆ هەمووان وەک یەکە؛ (ب) سەبەتەی کڕینی دوکانێکی ئۆنلاین؛ (ج) لاپەڕەیەکی کەشوهەوا کە پلەی گەرمیی ئەمڕۆی هەولێر پیشان دەدات؛ (د) لاپەڕەیەک کە وێنەیەکی جێگیری قەڵا پیشان دەدات؛ (هـ) ئەو لاپەڕەیەی دوای ئەنجامی تاقیکردنەوەکانت پیشان دەدات.
Show answerوەڵامەکە پیشان بدە
- (a) Static: the same file for every visitor.
- (b) Dynamic: each visitor has their own cart, built from saved data.
- (c) Dynamic: the temperature changes, so the page is built with new data.
- (d) Static: nothing in the page changes.
- (e) Dynamic: it depends on who logged in and reads data from a database.
- (أ) : هەمان بۆ هەموو سەردانیکەرێک.
- (ب) : هەر سەردانیکەرێک سەبەتەی خۆی هەیە، کە لە پاشەکەوتکراو دروست دەکرێت.
- (ج) : پلەی گەرمی دەگۆڕێت، بۆیە لاپەڕەکە بە نوێ دروست دەکرێت.
- (د) : هیچ شتێکی لاپەڕەکە ناگۆڕێت.
- (هـ) : بەستراوەتەوە بەوەی کێ چووەتە ژوورەوە و لە دەخوێنێتەوە.
For each job, say whether it happens on the server (PHP) or on the client (the browser): (a) checking a username and password against the database; (b) changing a button's colour when the mouse moves over it; (c) saving a new comment; (d) building a page that shows the server's date.
بۆ هەر کارێک بڵێ لەسەر (PHP) ڕوودەدات یان لای (): (أ) پشکنینی و بە بەراورد لەگەڵ ؛ (ب) گۆڕینی ڕەنگی دوگمەیەک کاتێک دەچێتە سەری؛ (ج) پاشەکەوتکردنی کۆمێنتێکی نوێ؛ (د) دروستکردنی لاپەڕەیەک کە بەرواری پیشان دەدات.
Show answerوەڵامەکە پیشان بدە
- (a) Server: the database and the passwords stay on the server.
- (b) Client: CSS or JavaScript in the browser does this.
- (c) Server: the comment must be saved where every visitor can later read it.
- (d) Server: PHP reads the server's clock, as in
time.phpabove.
- (أ) : و لەسەر دەمێننەوە.
- (ب) : CSS یان JavaScript لەناو ئەمە دەکات.
- (ج) : کۆمێنتەکە دەبێت لە شوێنێک پاشەکەوت بکرێت کە دواتر هەموو سەردانیکەرێک بتوانێت بیخوێنێتەوە.
- (د) : PHP کاتژمێری دەخوێنێتەوە، وەک
time.phpی سەرەوە.
Save the page.php example from PHP works together with HTML in the htdocs folder of , and open http://localhost/page.php. Then right-click the page and choose View Page Source. Can you find <?php anywhere? Finally, copy the same file to page.html, open http://localhost/page.html, and compare.
نموونەی page.php لە بەشی PHP و HTML پێکەوە کار دەکەن لە htdocsی پاشەکەوت بکە و http://localhost/page.php بکەرەوە. پاشان ڕاست لەسەر لاپەڕەکە بکە و View Page Source هەڵبژێرە. دەتوانیت <?php لە هیچ شوێنێک بدۆزیتەوە؟ لە کۆتاییدا هەمان بە ناوی page.html کۆپی بکە، http://localhost/page.html بکەرەوە و بەراوردیان بکە.
Hintئاماژە
Setting up XAMPP is explained in XAMPP: a local web server.
دامەزراندنی XAMPP لە وانەی XAMPP: ڕاژەکاری ناوخۆیی ڕوون کراوەتەوە.
Show answerوەڵامەکە پیشان بدە
In page.php the source shows <p>Today is Friday.</p> (with the real day): no PHP code at all. In page.html the server does not run PHP, so the browser receives <?php echo date("l"); ?> as it is. The browser hides it, so the page shows “Today is .”, but View Page Source shows the PHP code. This is why PHP files must end in .php.
لە page.phpدا View Page Source <p>Today is Friday.</p> پیشان دەدات (بە ڕۆژی ڕاستەقینەوە): هیچ کۆدێکی PHP نییە. لە page.htmlدا PHP جێبەجێ ناکات، بۆیە <?php echo date("l"); ?> وەک خۆی وەردەگرێت. دەیشارێتەوە، بۆیە لاپەڕەکە «Today is .» پیشان دەدات، بەڵام View Page Source کۆدی PHPـەکە پیشان دەدات. لەبەر ئەمەیە PHP دەبێت بە .php کۆتاییان بێت.
Summaryپوختە
- PHP (“PHP: Hypertext Preprocessor”, first “Personal Home Page”) is a free, open-source, server-side scripting language for building dynamic websites.
- Rasmus Lerdorf created it in 1994 to count visitors to his website, and made it public in June 1995.
- A static page is the same for everyone. A dynamic page is built by a program, often with data from a database.
- PHP code is embedded in HTML. The server runs it and sends only HTML to the browser, so visitors never see the PHP code.
- PHP runs on many operating systems and servers, supports many databases, is easy to learn and has a big library and community.
- PHP can work with forms, databases, files, cookies and sessions, and can protect pages with a login.
- Hidden code is not the same as secure code: security depends on how you write your PHP.
- PHP («PHP: Hypertext Preprocessor»، لە سەرەتادا «Personal Home Page») زمانێکی بەخۆڕایی و بۆ دروستکردنی داینامیک.
- ڕاسمۆس لێردۆرف لە ساڵی 1994دا بۆ ژماردنی سەردانیکەرانی دروستی کرد و لە حوزەیرانی 1995دا بۆ خەڵکی بڵاوکردەوە.
- بۆ هەمووان وەک یەکە. دروستی دەکات، زۆرجار بە .
- کۆدی PHP لەناو HTMLـدا دادەکوترێت. جێبەجێی دەکات و تەنها HTML بۆ دەنێرێت، بۆیە سەردانیکەران هەرگیز کۆدی PHP نابینن.
- PHP لەسەر زۆر و کار دەکات، پشتگیریی زۆر دەکات، فێربوونی ئاسانە و و کۆمەڵگەیەکی گەورەی هەیە.
- PHP دەتوانێت لەگەڵ ، ، ، و کار بکات و دەتوانێت لاپەڕەکان بە بپارێزێت.
- کۆدی شاراوە هەمان کۆدی پارێزراو نییە: بەستراوەتەوە بەوەی چۆن PHPـەکەت دەنووسیت.
Questions to check yourself
پرسیار بۆ پشکنینی خۆت
What is the difference between a static and a dynamic web page?جیاوازیی نێوان لاپەڕەتۆڕی نەگۆڕ و لاپەڕەتۆڕی داینامیک چییە؟
A static page has fixed content that visitors cannot change; the server sends the same file to everyone. A dynamic page is built or changed by a program such as PHP, often for each visitor, and visitors can add or change content.
ناوەڕۆکی جێگیری هەیە کە سەردانیکەران ناتوانن بیگۆڕن؛ هەمان بۆ هەمووان دەنێرێت. وەک PHP دروستی دەکات یان دەیگۆڕێت، زۆرجار بۆ هەر سەردانیکەرێک و سەردانیکەران دەتوانن ناوەڕۆک زیاد بکەن یان بگۆڕن.
Why must a file that contains PHP code end in .php?بۆچی فایلێک کە کۆدی PHPـی تێدایە دەبێت بە .php کۆتایی بێت؟
Because the web server uses the extension to decide whether to give the file to PHP. A .html file is sent as it is, so its PHP code does not run.
چونکە بە بڕیار دەدات کە بداتە PHP یان نا. .html وەک خۆی دەنێردرێت، بۆیە کۆدی PHPـەکەی جێبەجێ نابێت.
Name the three main jobs of PHP from the Kurdish notes.سێ کارە سەرەکییەکەی PHP لە تێبینییە کوردییەکانەوە ناو ببە.
Working with HTML forms; talking to many kinds of databases; protecting page content with a username and an authorised password.
مامەڵەکردن لەگەڵ HTML؛ گفتوگۆکردن لەگەڵ زۆر جۆری ؛ پاراستنی ناوەڕۆکی لاپەڕەکان بە و ڕێگەپێدراو.
Is PHP the same kind of language as JavaScript?ئایا PHP هەمان جۆری زمانی JavaScriptـە؟
No. PHP is server-side: it runs on the server and the visitor never sees it. JavaScript in a web page is client-side: it is sent to the browser and runs there.
نەخێر. PHP : لەسەر کار دەکات و سەردانیکەر هەرگیز نایبینێت. JavaScript لە : بۆ دەنێردرێت و لەوێ کار دەکات.
Any questions?هیچ پرسیارێک؟
The lecture slides end with “Thank you for your attention! Any questions?”. Write down anything that is still unclear and check it in the next lectures: PHP Syntax and Output with echo and print.
سلایدەکانی وانەکە بە «سوپاس بۆ سەرنجتان! هیچ پرسیارێک؟» کۆتاییان دێت. هەر شتێک هێشتا ڕوون نییە بینووسە و لە وانەکانی داهاتوودا بیپشکنە: داڕستنی PHP و دەرخستە بە echo و print.
Videoڤیدیۆ
Watch a videoسەیری ڤیدیۆیەک بکە
A video that viewers liked a lot and praised in their comments, chosen for this lesson.ڤیدیۆیەک کە بینەران زۆریان پێ خۆش بووە و لە کۆمێنتەکانیاندا ستایشیان کردووە، بۆ ئەم وانەیە هەڵبژێردراوە.
A calm answer to three questions: what PHP is, why people use it and what you can build with it, and whether PHP is 'dead'.
بە ئارامی وەڵامی سێ پرسیار دەداتەوە: چییە، بۆچی خەڵک بەکاری دەهێنن و چیی پێ دروست دەکرێت و ئایا «مردووە»؟
Watch 1:10 to 4:02: what PHP is and why use it
لە 1:10 تا 4:02 سەیر بکە: چییە و بۆچی بەکاری بهێنین.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
PHP Syntax: Tags, Statements and Commentsداڕستنی PHP: تاگ، ڕستە و لێدوان
Related lecturesوانە پەیوەندیدارەکان
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.