Chapterبەش 1 · Lectureوانە 1.3

HTTP and the Request–Response CycleHTTP و سووڕی داواکاری و وەڵام

What HTTP and HTTPS are, what is inside a request and a response, why PHP is a server-side language, the operational trail of a PHP page on the server, how a browser loads a whole page, and why HTTP is stateless.

و چین، چی لەناو و ، بۆچی زمانێکی ، ڕێچکەی کارکردنی لاپەڕەیەکی لەسەر ، چۆن تەواوی لاپەڕەیەک دەکاتەوە و بۆچی .

21 min read22 خولەک خوێندنەوە · 20 stepsهەنگاو

What you will learnچی فێر دەبیت

  • Explain what HTTP and HTTPS are and name the parts of a request and a response.
  • Read common status codes such as 200, 302, 404 and 500.
  • Explain why PHP is server-side and describe the operational trail of a PHP page.
  • Describe every step of loading a web page, including the separate requests for CSS, pictures and scripts.
  • Explain what stateless means and how cookies and sessions keep state.
  • ڕوونی بکەیتەوە و چین و ناوی بەشەکانی و بهێنیت.
  • وەک ⁦200⁩، ⁦302⁩، ⁦404⁩ و ⁦500⁩ بخوێنیتەوە.
  • ڕوونی بکەیتەوە بۆچی و ڕێچکەی کارکردنی لاپەڕەیەکی باس بکەیت.
  • هەموو هەنگاوێکی کردنەوەی باس بکەیت، لەگەڵ بۆ ، وێنە و .
  • ڕوونی بکەیتەوە واتای چییە و و چۆن دۆخ دەهێڵنەوە.

A short conversation, millions of times a dayگفتوگۆیەکی کورت، ملیۆنان جار لە ڕۆژێکدا

Every time you open a web page, your browser and a web server have a short conversation. The browser asks; the server answers. The rules of this conversation are called HTTP. When you write PHP, you are writing the server's side of this conversation, so it is worth knowing it well.

هەر جارێک دەکەیتەوە، و گفتوگۆیەکی کورت دەکەن. داوا دەکات؛ دەداتەوە. یاساکانی ئەم گفتوگۆیە پێیان دەوترێت . کاتێک دەنووسیت، بەشی ئەم گفتوگۆیە دەنووسیت، بۆیە شایەنی ئەوەیە بە باشی بیناسیت.

In this lecture you will learn:

لەم وانەیەدا فێری ئەمانە دەبیت:

  • What HTTP and HTTPS are, and what a request and a response look like inside.
  • Why PHP is called a server-side language: what happens to a .php file on the server (the "operational trail").
  • Everything that happens after the HTML arrives in the browser.
  • Why HTTP is stateless, and how cookies and sessions help a website remember you.
  • و چین و و لە ناوەوە چۆنن.
  • بۆچی پێی دەوترێت زمانێکی : فایلێکی .php لەسەر چی بەسەر دێت («ڕێچکەی کارکردن»).
  • هەموو ئەو شتانەی دوای گەیشتنی بۆ ڕوودەدەن.
  • بۆچی و و چۆن یارمەتیی دەدەن تۆ بناسێتەوە.

What is HTTP?HTTP چییە؟

HTTP stands for HyperText Transfer Protocol. It is the protocol used for communication between a client (usually a web browser) and a server on the World Wide Web. In simple words: HTTP is the language browsers and servers use to ask for and send pages.

کورتکراوەی ⁦HyperText Transfer Protocol⁩ـە. ئەو کە بۆ پەیوەندیکردن لە نێوان (بە زۆری ) و لەسەر بەکار دێت. بە زمانێکی سادە: ئەو زمانەیە کە و بۆ داواکردن و ناردنی لاپەڕەکان بەکاری دەهێنن.

Definitionپێناسە

The that browsers and servers use to ask for and send . Every exchange is one and one .

کە و بۆ داواکردن و ناردنی بەکاری دەهێنن. هەر ئاڵوگۆڕێک لە یەک و یەک پێکدێت.

The conversation always has the same shape:

گفتوگۆکە هەمیشە هەمان شێوەی هەیە:

  • The client always starts. It sends a request: "please give me /hello.php".
  • The server sends back exactly one response: the page, or a message that something went wrong.
  • Then the conversation is over. For the next page, a new request starts a new conversation.
  • هەمیشە دەست پێدەکات. دەنێرێت: «تکایە /hello.phpم بدەرێ».
  • تەنها یەک دەنێرێتەوە: لاپەڕەکە، یان پەیامێک کە شتێک نادروست ڕۆیشتووە.
  • پاشان گفتوگۆکە تەواو دەبێت. بۆ لاپەڕەی داهاتوو، نوێ گفتوگۆیەکی نوێ دەست پێدەکات.
Ordering teaداواکردنی چا

HTTP is like ordering at a tea house. You (the client) say to the waiter: "one tea, without sugar, please" (the request). The waiter (the server) brings your tea, or says "sorry, we have no tea today" (the response). Both sides know the polite, fixed way to order and to answer, so it works with any customer and any waiter.

وەک داواکردنی چا لە چایخانەیەک وایە. تۆ () بە چایچییەکە دەڵێیت: «تکایە چایەک بێ شەکر» (). چایچییەکە () چاکەت بۆ دەهێنێت، یان دەڵێت «ببورە، ئەمڕۆ چامان نییە» (). هەردوولا ڕێگای ڕێکوپێک و دیاریکراوی داواکردن و دەزانن، بۆیە لەگەڵ هەر کڕیارێک و هەر چایچییەک کار دەکات.

Where the analogy stops workingسنووری ئەم نموونەیە

A good waiter remembers you after a few visits. HTTP does not: every request is new to the server. See HTTP is stateless.

چایچییەکی باش دوای چەند سەردانێک دەتناسێتەوە. وا نییە: هەموو بۆ نوێیە. سەیری HTTP بێ‌دۆخە بکە.

What is HTTP?HTTP چییە؟

HTTPS: the secure versionHTTPS: وەشانە پارێزراوەکە

Plain HTTP sends everything as readable text. Anyone between the browser and the server (for example, someone on the same public Wi-Fi) could read the pages, the form data and even your password, or change them on the way.

سادە هەموو شتێک وەک دەقی خوێنراوە دەنێرێت. هەر کەسێک لە نێوان و (بۆ نموونە کەسێک لەسەر هەمان ⁦Wi-Fi⁩ـی گشتی) دەتوانێت لاپەڕەکان، دراوەکانی و تەنانەت بخوێنێتەوە، یان لە نێوەڕێدا بیانگۆڕێت.

HTTPS is HTTP protected with (a system called TLS). The browser shows a padlock next to the address, and the URL starts with https://. HTTPS normally uses port 443 instead of 80. Today almost every website uses HTTPS, and any page with a login or a form must use it.

بریتییە لە کە بە پارێزراوە (بە سیستەمێک بە ناوی TLS). قوفڵێک لە تەنیشت ناونیشانەکە پیشان دەدات و بە https:// دەست پێدەکات. بە ئاسایی ⁦443⁩ لە جیاتی ⁦80⁩ بەکار دەهێنێت. ئەمڕۆ نزیکەی هەموو بەکار دەهێنن و هەر لاپەڕەیەک کە یان تێدا بێت دەبێت بەکاری بهێنێت.

Definitionپێناسە

The secure version of . It uses TLS , so nobody between the browser and the server can read or change the data.

وەشانە پارێزراوەکەی . TLS بۆ بەکار دەهێنێت، بۆیە هیچ کەسێک لە نێوان تۆڕگەڕ و ڕاژەکاردا ناتوانێت دراوەکان بخوێنێتەوە یان بیانگۆڕێت.

Quick checkپشکنینی خێراWhat does HTTPS add to HTTP? چی زیاد دەکات بۆ ؟

SSL, TLS, HTTP, HTTPS ExplainedPowerCert Animated Videos · Englishئینگلیزی · 2.8M viewsبینین · 53K likesلایک

See why plain HTTP can be read by an attacker, and how HTTPS encrypts the conversation between browser and server.

ببینە بۆچی هێرشبەرێک دەتوانێت ناوەڕۆکی ئاسایی بخوێنێتەوە و چۆن بە گفتوگۆی نێوان و دەپارێزێت.

Whole video: HTTP vs HTTPS, then SSL/TLS basics

هەموو ڤیدیۆکە: جیاوازیی و ، پاشان بنەماکانی ⁦SSL/TLS⁩.

Inside a request and a responseناوەوەی داواکارییەک و وەڵامێک

A request and a response are short text messages. You never type them yourself: the browser writes the request, and the web server (with PHP) writes the response. But reading them once makes everything else in this course easier.

و پەیامی دەقیی کورتن. هەرگیز خۆت نایاننووسیت: دەنووسێت و (لەگەڵ ) دەنووسێت. بەڵام ئەگەر جارێک بیانخوێنیتەوە، هەموو شتێکی تری ئەم کۆرسە ئاسانتر دەبێت.

Two text messages with coloured parts. The request, from browser to server: a request line GET /hello.php HTTP/1.1 (method, path, HTTP version), then headers such as Host: www.example.com, User-Agent and Accept: text/html (extra information written as Name: value), then a blank line that ends the headers; a GET request has no body. The response, from server to browser: a status line HTTP/1.1 200 OK (version, status code, reason), then headers such as Date, Content-Type: text/html; charset=UTF-8 and Content-Length: 142, then a blank line, then the body, which is the HTML page itself.دوو پەیامی دەقی بە بەشی ڕەنگاوڕەنگەوە. داواکارییەکە، لە تۆڕگەڕەوە بۆ ڕاژەکار: دێڕی داواکاری GET /hello.php HTTP/1.1 (ڕێگای HTTP، ڕێڕەو، وەشانی HTTP)، پاشان سەردێڕەکانی HTTP وەک Host: www.example.com، User-Agent و Accept: text/html (زانیاریی زیادە کە بە شێوەی Name: value دەنووسرێت)، پاشان دێڕێکی بەتاڵ کە کۆتایی بە سەردێڕەکان دەهێنێت؛ داواکارییەکی GET لاشەی نییە. وەڵامەکە، لە ڕاژەکارەوە بۆ تۆڕگەڕ: دێڕی دۆخ HTTP/1.1 200 OK (وەشان، کۆدی دۆخ، هۆکار)، پاشان سەردێڕەکانی HTTP وەک Date، Content-Type: text/html; charset=UTF-8 و Content-Length: 142، پاشان دێڕێکی بەتاڵ، پاشان لاشەکە کە خودی لاپەڕە HTMLـەکەیە.
The parts of an HTTP request and an HTTP response.بەشەکانی و .CêIT

Inside a request and a responseناوەوەی داواکارییەک و وەڵامێک

The requestداواکارییەکە

An HTTP request for hello.phpداواکارییەکی HTTP بۆ ⁦hello.php⁩HTTP
GET /hello.php HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Accept: text/html
Accept-Language: ckb, en
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 1

The request line: the method GET ("give me"), the path /hello.php and the HTTP version.

دێڕی : GET («بمدەرێ»)، /hello.php و وەشانی .

Lineدێڕی 2

Host names the website. One server can keep many websites, so it must know which one you want.

Host ناوی دەڵێت. یەک دەتوانێت چەندین هەڵبگرێت، بۆیە دەبێت بزانێت تۆ کامیانت دەوێت.

Lineدێڕی 3

User-Agent says which browser and operating system is asking.

User-Agent دەڵێت کام و کام داوا دەکات.

Lineدێڕی 4-5

Accept says what kind of data the browser expects (here HTML). Accept-Language lists the languages the user prefers (ckb is Central Kurdish).

Accept دەڵێت چاوەڕێی چ جۆرە دراوەیەک دەکات (لێرەدا ). Accept-Language ئەو زمانانە دەژمێرێت کە بەکارهێنەر پێی باشترە (ckb واتە کوردیی ناوەندی).

Lineدێڕی 6

An empty line ends the headers. A GET request has no body after it.

دێڕێکی بەتاڵ کۆتایی بە دەهێنێت. GET لە دوای ئەوە لاشەی نییە.

The first word of the request is the HTTP method. In this course you will use two of them:

یەکەم وشەی ـە. لەم کۆرسەدا دوویان بەکار دەهێنیت:

The two methods you will use mostدوو کە زۆرتر بەکاریان دەهێنیت
MethodMeaningواتاWhere the data goesدراوەکان لە کوێ دەڕۆن
GET"Give me this page." Used when you type a URL or click a link.«ئەم لاپەڕەیەم بدەرێ.» کاتێک دەنووسیت یان کرتە لە دەکەیت بەکار دێت.In the URL, as a query string: ?id=5لەناو ، وەک : ?id=5
POST"Here is some data for you." Used by forms that send or save data.«ئەمە هەندێک دراوەیە بۆ تۆ.» بەکاری دەهێنن کاتێک دراوە دەنێرن یان پاشەکەوت دەکەن.In the body of the request, after the headersلە لاشەی ، دوای

You will use both of them with PHP forms in Form handling with GET and POST.

هەردووکیان لەگەڵ لە وانەی مامەڵەکردن لەگەڵ فۆرم بە GET و POST بەکار دەهێنیت.

Quick checkپشکنینی خێراYou type a URL and press Enter. Which HTTP method does the browser use? دەنووسیت و Enter دادەگریت. کام بەکار دەهێنێت؟

Inside a request and a responseناوەوەی داواکارییەک و وەڵامێک

The responseوەڵامەکە

The HTTP response for hello.phpوەڵامی HTTP بۆ ⁦hello.php⁩HTTP
HTTP/1.1 200 OK
Date: Fri, 16 Oct 2026 10:00:00 GMT
Server: Apache
Content-Type: text/html; charset=UTF-8
Content-Length: 142

<!DOCTYPE html>
<html>
<head>
  <title>Hello</title>
</head>
<body>
  <h1>Welcome</h1>
  <p>Hello, Aram!</p>
<p>2 + 3 = 5</p>
</body>
</html>
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 1

The status line: the version, the status code 200 and its reason OK. It tells the browser how the request went.

دێڕی دۆخ: وەشان، 200 و هۆکارەکەی OK. بە دەڵێت چۆن ڕۆیشت.

Lineدێڕی 3

Server names the web server program, here Apache.

Server ناوی دەڵێت، لێرەدا .

Lineدێڕی 4

Content-Type says what the body is: an HTML page written in UTF-8, the character set that can show Kurdish letters.

Content-Type دەڵێت لاشەکە چییە: لاپەڕەیەکی کە بە ⁦UTF-8⁩ نووسراوە، ئەو کۆمەڵە پیتەی دەتوانێت پیتە کوردییەکان پیشان بدات.

Lineدێڕی 5

Content-Length is the size of the body in bytes (here 142).

Content-Length قەبارەی لاشەکەیە بە بایت (لێرەدا ⁦142⁩).

Lineدێڕی 7-17

The body: the HTML that PHP produced. This is the only part the browser draws.

لاشە: ئەو بەرهەمی هێناوە. ئەمە تاکە بەشە کە دەیکێشێت.

Quick checkپشکنینی خێراWhich part of the response does the browser draw on the screen? کام بەشی لەسەر شاشە دەکێشێت؟

Inside a request and a responseناوەوەی داواکارییەک و وەڵامێک

Status codesکۆدەکانی دۆخ

When the server cannot find the file, it still sends a response, but with an error status code and a short error page:

کاتێک فایلەکە نادۆزێتەوە، هەر دەنێرێت، بەڵام بە و لاپەڕەیەکی کورتی :

A 404 responseوەڵامێکی ⁦404⁩HTTP
HTTP/1.1 404 Not Found
Date: Fri, 16 Oct 2026 10:00:05 GMT
Server: Apache
Content-Type: text/html; charset=UTF-8

<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
Status codes you will meet کە دەیانبینیت
CodeکۆدNameناوWhat it meansواتای چییە
200OKEverything worked; the body holds the page.هەموو شتێک باش ڕۆیشت؛ لاشەکە لاپەڕەکەی تێدایە.
301Moved PermanentlyThe page has a new address forever; the browser goes there.لاپەڕەکە بۆ هەمیشە ناونیشانێکی نوێی هەیە؛ دەچێتە ئەوێ.
302FoundA temporary : go to another address this time. PHP's header("Location: ...") sends this. کاتی: ئەم جارە بچۆ بۆ ناونیشانێکی تر. header("Location: ...")ی ئەمە دەنێرێت.
403ForbiddenThe file exists, but you are not allowed to see it.فایلەکە هەیە، بەڵام ڕێگەت پێنادرێت بیبینیت.
404Not FoundThere is no file at this path. Check the spelling of the URL.هیچ فایلێک لەم نییە. نووسینی بپشکنە.
500Internal Server ErrorSomething broke on the server, for example a fatal error in your PHP code.شتێک لەسەر تێکچوو، بۆ نموونە لە کۆدی .
Quick checkپشکنینی خێراWhat does the status code 404 mean? 404 واتای چییە؟

PHP: a server-side languagePHP: زمانێکی ڕاژەبەند

PHP is called a server-side language because its code runs on the web server, not in the browser. Look at the journey of one PHP page:

پێی دەوترێت زمانێکی ، چونکە کۆدەکەی لەسەر کار دەکات، نەک لە . سەیری گەشتی یەک لاپەڕەی بکە:

On the left, the user's computer with the browser, the client. On the right, the web server, which holds the file hello.php (PHP code, stored here), a PHP interpreter that runs the code, and the HTML output. Step 1: an HTTP request, GET /hello.php, goes from the browser to the server. Step 2: the PHP interpreter runs the code. Step 3: an HTTP response, 200 OK plus HTML, goes back to the browser. A note says the PHP code never leaves the server; the browser receives only the HTML that PHP printed.لە لای چەپ، کۆمپیوتەری بەکارهێنەر لەگەڵ تۆڕگەڕ، کە ڕاژەخوازە. لە لای ڕاست، ڕاژەکاری وێب کە فایلی hello.php (کۆدی PHP کە لێرە هەڵگیراوە)، ئینتەرپرێتەری PHP کە کۆدەکە جێبەجێ دەکات و دەرخستەی HTMLـی تێدایە. هەنگاوی ١: داواکارییەکی HTTP، GET /hello.php، لە تۆڕگەڕەوە دەچێت بۆ ڕاژەکار. هەنگاوی ٢: ئینتەرپرێتەری PHP کۆدەکە جێبەجێ دەکات. هەنگاوی ٣: وەڵامێکی HTTP، 200 OK و HTML، دەگەڕێتەوە بۆ تۆڕگەڕ. تێبینییەک دەڵێت کۆدی PHP هەرگیز لە ڕاژەکار دەرناچێت؛ تۆڕگەڕ تەنها ئەو HTMLـە وەردەگرێت کە PHP چاپی کردووە.
PHP runs on the server. The browser sends a request and receives only HTML. لەسەر کار دەکات. دەنێرێت و تەنها وەردەگرێتەوە.CêIT
  1. The browser asksتۆڕگەڕەکە داوا دەکات

    The browser on the user's computer sends an HTTP request for the page hello.php.

    لەسەر کۆمپیوتەری بەکارهێنەر بۆ لاپەڕەی hello.php دەنێرێت.

  2. The server processesڕاژەکارەکە کار لەسەر دەکات

    The web server finds hello.php. The PHP interpreter runs the code inside it ("processing"). Whatever the code prints becomes HTML.

    hello.php دەدۆزێتەوە. کۆدەکەی ناوی جێبەجێ دەکات («کارلەسەرکردن»). هەر شتێک کۆدەکە چاپی بکات دەبێت بە .

  3. An HTML page comes backلاپەڕەیەکی HTML دەگەڕێتەوە

    The server sends back an HTML page. The browser draws it. The PHP code itself stays on the server.

    لاپەڕەیەکی دەنێرێتەوە. دەیکێشێت. خودی کۆدی لەسەر دەمێنێتەوە.

Quick checkپشکنینی خێراWhat does the browser receive when it asks for hello.php?کاتێک داوای hello.php دەکات، چی وەردەگرێت؟

Client Side vs Server Side Programming - Basic ConceptsStefan Mischook · Englishئینگلیزی · 51K viewsبینین · 1.1K likesلایک · Partبەشی 0:42–9:03 (ofلە 10:19)

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–9:03, client-side vs server-side code

لە ⁦0:42⁩ تا ⁦9:03⁩ سەیر بکە: جیاوازیی کۆدی و کۆدی .

PHP: a server-side languagePHP: زمانێکی ڕاژەبەند

Three views of the same pageسێ دیمەنی هەمان لاپەڕە

Here is a small PHP page. Compare what you write, what the server sends, and what the visitor sees.

ئەمە لاپەڕەیەکی بچووکی . بەراوردی بکە: ئەوەی تۆ دەینووسیت، ئەوەی دەینێرێت و ئەوەی سەردانکەر دەیبینێت.

1. What you write (stored on the server)١. ئەوەی تۆ دەینووسیت (لەسەر ڕاژەکار هەڵگیراوە)hello.phpPHPRuns on the serverلەسەر ڕاژەکاری وێب کار دەکات
<!DOCTYPE html>
<html>
<head>
  <title>Hello</title>
</head>
<body>
  <h1>Welcome</h1>
  <?php
  $name = "Aram";
  echo "<p>Hello, $name!</p>\n";
  echo "<p>2 + 3 = " . (2 + 3) . "</p>\n";
  ?>
</body>
</html>
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 1-7

Plain HTML. PHP does not touch it; it is sent exactly as written.

سادە. دەستی لێ نادات؛ هەروەک خۆی دەنێردرێت.

Lineدێڕی 8-12

The PHP block between <?php and ?>. The server runs it: it stores the name Aram in $name, and echo prints two paragraphs of HTML.

بلۆکی لە نێوان <?php و ?>. جێبەجێی دەکات: ناوی ئارام لە $nameدا هەڵدەگرێت و echo دوو بڕگەی چاپ دەکات.

Lineدێڕی 11

2 + 3 is calculated on the server; the browser receives only the result 5.

2 + 3 لەسەر هەژمار دەکرێت؛ تەنها ئەنجامەکەی وەردەگرێت: 5.

If you choose View Page Source in the browser (Ctrl+U), you see the HTML of view 2, never the PHP of view 1. That is why visitors cannot read your PHP code, and why passwords written inside PHP code stay on the server.

ئەگەر لە ⁦View Page Source⁩ هەڵبژێریت ⁦(Ctrl+U)⁩، دیمەنی ٢ دەبینیت، هەرگیز دیمەنی ١ نابینیت. بۆیە سەردانکەران ناتوانن کۆدی بخوێننەوە و بۆیە هەر لەناو کۆدی بنووسرێت، لەسەر دەمێنێتەوە.

The operational trail: inside the serverڕێچکەی کارکردن: لەناو ڕاژەکاردا

What happens when you actually ask for a URL in your browser, before you get HTML back to you? The course calls this path the operational trail. Let us follow a request for hello.php inside the server.

کاتێک بە ڕاستی لە داوای دەکەیت، پێش ئەوەی بگەڕێتەوە بۆت، چی ڕوودەدات؟ کۆرسەکە بەم ڕێگایە دەڵێت ڕێچکەی کارکردن ⁦(operational trail)⁩. با بەدوای بۆ hello.php لەناو بکەوین.

The browser is on the left. A large box on the right is the server. Inside it, a dashed box is Apache, the web server, with two steps: Find the page, and Return the HTML. Next to Apache are the file hello.php, a Process PHP box (the PHP interpreter) and a database. Numbered arrows: 1 from the browser to Find the page; 2 from Find the page to hello.php; 3 from hello.php down to Process PHP; 4 a two-way arrow between Process PHP and the database; 5 from Process PHP to Return the HTML; 6 from Return the HTML back to the browser.تۆڕگەڕ لە لای چەپە. سندوقێکی گەورە لە لای ڕاست ڕاژەکارە. لەناویدا سندوقێکی پچڕپچڕ Apacheـە، واتە ڕاژەکاری وێب، بە دوو هەنگاوەوە: لاپەڕەکە بدۆزەرەوە و HTMLـەکە بنێرەوە. لە تەنیشت Apacheـەوە فایلی hello.php، سندوقی جێبەجێکردنی PHP (ئینتەرپرێتەری PHP) و بنکەدراوەیەک هەن. تیرە ژمارەدارەکان: ١ لە تۆڕگەڕەوە بۆ «لاپەڕەکە بدۆزەرەوە»؛ ٢ لەوێوە بۆ hello.php؛ ٣ لە hello.php بۆ خوارەوە بۆ جێبەجێکردنی PHP؛ ٤ تیرێکی دوولایەنە لە نێوان جێبەجێکردنی PHP و بنکەدراوەکە؛ ٥ لە جێبەجێکردنی PHP بۆ «HTMLـەکە بنێرەوە»؛ ٦ لەوێوە دەگەڕێتەوە بۆ تۆڕگەڕ.
The operational trail: what happens on the server between your request and the HTML you get back.ڕێچکەی کارکردن: ئەوەی لەسەر ڕوودەدات لە نێوان و ئەو وەریدەگریتەوە.CêIT
  1. Requestداواکاری

    The browser sends a request for /hello.php to the server.

    بۆ /hello.php دەنێرێت بۆ .

  2. Find the pageلاپەڕەکە بدۆزەرەوە

    Apache looks for the file hello.php in its document folder (in XAMPP, the htdocs folder). If it is not there, Apache answers 404 Not Found and the trail ends here.

    لە بەڵگەنامەکانیدا (لە ، ) بەدوای فایلی hello.phpدا دەگەڕێت. ئەگەر لەوێ نەبێت، 404 Not Found دەداتەوە و ڕێچکەکە لێرە کۆتایی دێت.

  3. Hand it to PHPبیدە بە PHP

    The file name ends in .php, so Apache does not send the file as it is. It hands it to the PHP interpreter.

    ناوی فایلەکە بە .php کۆتایی دێت، بۆیە فایلەکە هەروەک خۆی نانێرێت. دەیدات بە .

  4. Process PHPجێبەجێکردنی PHP

    PHP runs the code from top to bottom. If the page needs data (a list of products, a user's name), PHP reads it from, or saves it to, a database such as MySQL.

    کۆدەکە لە سەرەوە بۆ خوارەوە جێبەجێ دەکات. ئەگەر لاپەڕەکە پێویستی بە دراوە بێت (لیستی کاڵاکان، ناوی بەکارهێنەرێک)، لە وەک دەیخوێنێتەوە یان تێیدا پاشەکەوتی دەکات.

  5. Return HTMLHTML بنێرەوە

    Everything PHP printed is now plain HTML. It goes back to Apache.

    هەموو ئەو شتانەی چاپی کردوون ئێستا سادەن. دەگەڕێنەوە بۆ .

  6. Responseوەڵام

    Apache sends the HTML to the browser in an HTTP response, and the browser draws the page.

    لە دەنێرێت بۆ و لاپەڕەکە دەکێشێت.

The operational trail: inside the serverڕێچکەی کارکردن: لەناو ڕاژەکاردا

Why the .php extension mattersبۆچی پاشگری فایلی .php گرنگە

Why the .php file extension mattersبۆچی .php گرنگە
File the browser asks forئەو فایلەی داوای دەکاتWhat the server does چی دەکات
about.html, style.css, logo.pngApache sends the file exactly as it is. PHP is not involved. فایلەکە هەروەک خۆی دەنێرێت. بەشدار نییە.
hello.phpApache gives the file to PHP, PHP runs it, and only its HTML output is sent. فایلەکە دەدات بە ، جێبەجێی دەکات و تەنها دەنێردرێت.
Quick checkپشکنینی خێراThe browser asks for style.css. What does Apache do? داوای style.css دەکات. چی دەکات؟

After the HTML arrives: loading the whole pageدوای گەیشتنی HTML: کردنەوەی تەواوی لاپەڕەکە

A real web page is more than one HTML file. It also needs CSS, pictures and JavaScript. Here is the whole story, from pressing Enter to a finished page:

ڕاستەقینە لە یەک فایلی زیاترە. پێویستی بە ، وێنە و هەیە. ئەمە هەموو چیرۆکەکەیە، لە داگرتنی Enterـەوە تا لاپەڕەیەکی تەواو:

  1. You press EnterEnter دادەگریت

    You type a URL and press Enter. The browser sends a request to the server that hosts the website. The request says what kind of data the browser expects to receive, such as HTML, images or other media (the Accept header).

    دەنووسیت و Enter دادەگریت. دەنێرێت بۆ ئەو هەڵدەگرێت. دەڵێت چاوەڕێی وەرگرتنی چ جۆرە دراوەیەک دەکات، وەک ، وێنە یان میدیای تر (سەردێڕی Accept).

  2. The server processes the requestڕاژەکارەکە کار لەسەر داواکارییەکە دەکات

    The server receives the request and starts to process it. If it finds the page, it sends the HTML document back in a response. For a .php page it first runs the PHP code (the operational trail above).

    وەردەگرێت و دەست دەکات بە کارکردن لەسەری. ئەگەر لاپەڕەکە بدۆزێتەوە، بەڵگەنامەی لە دەنێرێتەوە. بۆ لاپەڕەیەکی .php، سەرەتا کۆدی جێبەجێ دەکات (ڕێچکەی کارکردنی سەرەوە).

  3. Or an errorیان هەڵە

    If the server cannot find the page, or something else goes wrong, it sends a response with an error message and an error status code, such as 404 Not Found or 500 Internal Server Error.

    ئەگەر لاپەڕەکە نەدۆزێتەوە، یان شتێکی تر نادروست بڕوات، دەنێرێت کە پەیامی و تێدایە، وەک 404 Not Found یان 500 Internal Server Error.

  4. The browser reads the HTMLتۆڕگەڕەکە HTMLـەکە دەخوێنێتەوە

    The browser processes the HTML file, the backbone of every web page. It reads the HTML and builds a visual version of the page on your screen.

    کار لەسەر فایلی دەکات، کە ئێسکی پشتی هەموو . دەخوێنێتەوە و وێنەیەکی بینراوی لاپەڕەکە لەسەر شاشەکەت دروست دەکات.

  5. The browser fetches the extra filesتۆڕگەڕەکە فایلە زیادەکان دەهێنێت

    While reading, the browser finds tags such as <link> (CSS), <img> (pictures, videos) and <script> (JavaScript). For each of these files it sends a separate request and gets a separate response.

    لە کاتی خوێندنەوەدا، وەک <link> ()، <img> (وێنە، ڤیدیۆ) و <script> () دەدۆزێتەوە. بۆ هەر یەک لەم فایلانە جیا دەنێرێت و جیا وەردەگرێتەوە.

  6. The browser runs the JavaScriptتۆڕگەڕەکە JavaScript جێبەجێ دەکات

    Finally, the browser runs any JavaScript code on the page, so the page can react to the user and do dynamic things.

    لە کۆتاییدا، هەر کۆدێکی کە لە لاپەڕەکەدا هەبێت جێبەجێ دەکات، بۆ ئەوەی لاپەڕەکە کاردانەوەی بۆ بەکارهێنەر هەبێت و کاری داینامیک بکات.

After the HTML arrives: loading the whole pageدوای گەیشتنی HTML: کردنەوەی تەواوی لاپەڕەکە

One request for every fileداواکارییەک بۆ هەر فایلێک

A sequence diagram with a browser line on the left and a web server line on the right. 1: GET /index.php, answered by 200 OK with the HTML document. 2: the browser reads the HTML and finds it needs 3 more files. 3: GET /style.css, answered by 200 OK with the CSS file. 4: GET /logo.png, answered by 200 OK with the picture. 5: GET /app.js, answered by 404 Not Found because the file is missing. 6: the browser draws the page on the screen, then runs any JavaScript it received. A note says every file is a separate request and a separate response.وێنەیەکی ڕیزبەندی بە هێڵی تۆڕگەڕ لە چەپ و هێڵی ڕاژەکاری وێب لە ڕاست. ١: GET /index.php، کە بە 200 OK و بەڵگەنامە HTMLـەکە وەڵام دەدرێتەوە. ٢: تۆڕگەڕەکە HTMLـەکە دەخوێنێتەوە و دەبینێت پێویستی بە ٣ فایلی ترە. ٣: GET /style.css، کە بە 200 OK و فایلی CSS وەڵام دەدرێتەوە. ٤: GET /logo.png، کە بە 200 OK و وێنەکە وەڵام دەدرێتەوە. ٥: GET /app.js، کە بە 404 Not Found وەڵام دەدرێتەوە چونکە فایلەکە نییە. ٦: تۆڕگەڕەکە لاپەڕەکە لەسەر شاشە دەکێشێت، پاشان هەر JavaScriptـێک وەریگرتبێت جێبەجێی دەکات. تێبینییەک دەڵێت هەر فایلێک داواکارییەکی جیا و وەڵامێکی جیای هەیە.
Loading one page takes several requests: first the HTML, then one request for each extra file.کردنەوەی یەک لاپەڕە چەند دەوێت: سەرەتا ، پاشان بۆ هەر فایلێکی زیادە.CêIT
Quick checkپشکنینی خێراA page has one HTML file, one CSS file and two pictures. How many HTTP requests does the browser send to load it?لاپەڕەیەک یەک فایلی ، یەک فایلی و دوو وێنەی هەیە. چەند دەنێرێت بۆ کردنەوەی؟

HTTP is statelessHTTP بێ‌دۆخە

HTTP is a stateless protocol: it keeps no information about earlier requests or responses. Each request–response pair is independent of all the pairs before it.

ـە: هیچ زانیارییەک دەربارەی و هەڵناگرێت. هەر جووتێکی – سەربەخۆیە لە هەموو جووتەکانی پێش خۆی.

Definitionپێناسە

A stateless does not remember earlier requests: each is handled on its own. is stateless, so websites use and to remember users.

واتە هیچ داواکارییەکی پێشووی لە بیر نییە: هەر بە جیا مامەڵەی لەگەڵ دەکرێت. بێ‌دۆخە، بۆیە تۆڕگەکان و بەکار دەهێنن بۆ ئەوەی بەکارهێنەرەکانیان بناسنەوە.

For example, when you visit a website and click a link, the server receives a new request for the new page, with no information about the page you were on. The server does not "remember" anything about the previous request: not the information you typed into a form, and not anything else you did on the site.

بۆ نموونە، کاتێک سەردانی دەکەیت و کرتە لە دەکەیت، نوێ بۆ لاپەڕە نوێیەکە وەردەگرێت، بەبێ هیچ زانیارییەک دەربارەی ئەو لاپەڕەیەی پێشتر لەسەری بوویت. هیچ شتێک لە «لە بیر نییە»: نە ئەو زانیارییانەی لە نووسیوتن و نە هیچ کارێکی تر کە لەسەر کردووتە.

You can see this with PHP. Every request starts a fresh run of the script, with fresh variables:

دەتوانیت ئەمە بە ببینیت. هەموو لە سەرەتاوە کارپێدەکاتەوە، بە :

A counter that never countsژمێرەرێک کە هەرگیز ناژمێرێتcounter.phpPHPRuns on the serverلەسەر ڕاژەکاری وێب کار دەکات
<?php
$visits = 0;      // every request starts here
$visits++;        // add one
echo "<p>Visits: $visits</p>";
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 2

Each request creates $visits again and sets it to 0.

هەموو $visits دووبارە دروست دەکاتەوە و دەیکات بە 0.

Lineدێڕی 3

++ adds one, so $visits becomes 1.

++ یەک زیاد دەکات، بۆیە $visits دەبێت بە 1.

Lineدێڕی 4

The page prints 1. When the response is sent, the script ends and $visits is gone.

لاپەڕەکە 1 چاپ دەکات. کاتێک دەنێردرێت، کۆتایی دێت و $visits نامێنێت.

Quick checkپشکنینی خێراWhat does "HTTP is stateless" mean?« » واتای چییە؟

HTTP is statelessHTTP بێ‌دۆخە

How websites remember you: cookies and sessionsتۆڕگەکان چۆن دەتناسنەوە: کووکییەکان و سێشنەکان

To keep state (to remember things) between requests, web developers use two techniques:

بۆ هێشتنەوەی دۆخ (لەبیرکردنی شتەکان) لە نێوان ، گەشەپێدەرانی وێب دوو ڕێگا بەکار دەهێنن:

  • Cookies are small pieces of data stored on the client's computer. The server asks the browser to keep a cookie, and the browser sends it back with every later request to that site.
  • Server-side session management stores the session data on the server. The browser keeps only a short session ID (usually in a cookie), and the server uses it to find that visitor's data.
  • پارچە دراوەی بچووکن کە لەسەر کۆمپیوتەری هەڵدەگیرێن. داوا لە دەکات هەڵبگرێت و لەگەڵ هەموو دواتر بۆ ئەو دەینێرێتەوە.
  • بەڕێوەبردنی لە لای دراوەکانی لەسەر هەڵدەگرێت. تەنها کورت دەهێڵێتەوە (زۆرجار لە ) و بەکاری دەهێنێت بۆ دۆزینەوەی دراوەکانی ئەو سەردانکەرە.
Two sequence diagrams side by side. Left, HTTP alone: every request is new. The browser sends GET /page1.php and gets 200 OK; then it sends GET /page2.php, and the server thinks: who are you? I do not remember. It answers 200 OK and treats page 2 like a first visit. Right, with a cookie and a session: the browser sends GET /page1.php and gets 200 OK with Set-Cookie: PHPSESSID=abc123; the browser saves the cookie. Then it sends GET /page2.php with Cookie: PHPSESSID=abc123; the server looks up session abc123, user = Aram, and answers 200 OK: Welcome back, Aram!دوو وێنەی ڕیزبەندی لە تەنیشت یەکتر. چەپ، تەنها HTTP: هەموو داواکارییەک نوێیە. تۆڕگەڕەکە GET /page1.php دەنێرێت و 200 OK وەردەگرێت؛ پاشان GET /page2.php دەنێرێت و ڕاژەکارەکە بیر دەکاتەوە: تۆ کێیت؟ لە بیرم نییە. بە 200 OK وەڵام دەداتەوە و لاپەڕەی ٢ وەک یەکەم سەردان مامەڵە دەکات. ڕاست، لەگەڵ کووکی و سێشن: تۆڕگەڕەکە GET /page1.php دەنێرێت و 200 OK لەگەڵ Set-Cookie: PHPSESSID=abc123 وەردەگرێت؛ تۆڕگەڕەکە کووکییەکە هەڵدەگرێت. پاشان GET /page2.php لەگەڵ Cookie: PHPSESSID=abc123 دەنێرێت؛ ڕاژەکارەکە لە سێشنی abc123 دەگەڕێت، بەکارهێنەر = ئارام و بە 200 OK وەڵام دەداتەوە: بەخێربێیتەوە، ئارام!
Left: plain HTTP forgets you between pages. Right: a cookie carries a session ID, and the server keeps the data in a session.چەپ: سادە لە نێوان لاپەڕەکاندا لە بیرت دەکات. ڕاست: هەڵدەگرێت و دراوەکان لە دەهێڵێتەوە.CêIT
The bakery ticketپسوولەی نانەواخانە

A busy bakery serves hundreds of customers and cannot remember faces. When you order a birthday cake, the baker gives you a small ticket with a number (a cookie with a session ID) and writes your order in a notebook under that number (the session on the server). When you come back, you show the ticket, and the baker finds your order at once.

نانەواخانەیەکی قەرەباڵغ خزمەتی سەدان کڕیار دەکات و ناتوانێت ڕووخسارەکان لە بیر بگرێت. کاتێک کێکێکی ڕۆژی لەدایکبوون داوا دەکەیت، نانەواکە پسوولەیەکی بچووکت دەداتێ کە ژمارەیەکی لەسەرە ( کە تێدایە) و داواکەت لە دەفتەرێکدا لە ژێر ئەو ژمارەیەدا دەنووسێت ( لەسەر ). کاتێک دەگەڕێیتەوە، پسوولەکە پیشان دەدەیت و نانەواکە دەستبەجێ داواکەت دەدۆزێتەوە.

Where the analogy stops workingسنووری ئەم نموونەیە

Anyone who steals your ticket can collect your cake. In the same way, a stolen session ID lets someone act as you, which is one reason why logins must use HTTPS.

هەر کەسێک پسوولەکەت بدزێت دەتوانێت کێکەکەت ببات. بە هەمان شێوە، دزراو ڕێگە بە کەسێک دەدات خۆی بکات بە تۆ و ئەمە یەکێکە لە هۆکارەکانی ئەوەی بۆچی دەبێت بەکار بهێنێت.

Quick checkپشکنینی خێراWhere is the data of a session kept? لە کوێ هەڵدەگیرێن؟

How Sessions work in Web ServersBen Awad · Englishئینگلیزی · 78K viewsبینین · 1.2K likesلایک · Partبەشی 0:00–4:41 (ofلە 5:41)

See how a server remembers you: it gives your browser a session ID and keeps your data on the server.

ببینە چۆن تۆ دەناسێتەوە: دەداتە و لەسەر خۆی هەڵدەگرێت.

Watch 0:00–4:41, session IDs; stops before the JWT part

لە ⁦0:00⁩ تا ⁦4:41⁩ سەیر بکە: ؛ پێش بەشی JWT ڕادەوەستێت.

HTTP is statelessHTTP بێ‌دۆخە

Why is HTTP stateless?بۆچی HTTP بێ‌دۆخە؟

Why is HTTP designed like this? Because a server that remembers nothing is simple, and any server can answer any request. A big website can share millions of visitors among many servers. In short, being stateless allows greater scalability and a simpler implementation, but it also means extra work to keep state across several requests.

بۆچی بەم شێوەیە دیزاین کراوە؟ چونکە کە هیچ شتێکی لە بیر نەبێت سادەیە و هەر دەتوانێت هەر بداتەوە. گەورە دەتوانێت ملیۆنان سەردانکەر بەسەر چەندین دابەش بکات. بە کورتی، بوون ڕێگە بە فراوانبوونی زیاتر و دروستکردنێکی سادەتر دەدات، بەڵام واتای کاری زیادەشە بۆ هێشتنەوەی دۆخ لە نێوان چەند .

Common mistakesئەو هەڵانەی زۆرجار دەکرێن

  • Thinking the browser sends PHP code to the server. It sends a request for a page. The PHP code is already on the server.
  • Opening a .php file by double-clicking it. PHP only runs through the web server: use http://localhost/..., not file:///....
  • Expecting a variable to keep its value on the next page. HTTP is stateless and every request starts the script again. Use a session or a cookie to remember things.
  • Thinking one response carries the whole page. The HTML comes in one response; every CSS file, picture and script needs its own request.
  • Treating 404 as a bug in your PHP code. 404 Not Found means the server found no file at that path: check the file name, the folder and the URL. A PHP error gives 500 or an error message instead.
  • Sending passwords over plain http://. Any page with a login or a form must use https://.
  • وا بزانیت کۆدی دەنێرێت بۆ . بۆ لاپەڕەیەک دەنێرێت. کۆدی پێشتر لەسەر .
  • کردنەوەی فایلێکی .php بە دوو کرتە. تەنها لە ڕێگەی کار دەکات: http://localhost/... بەکار بهێنە، نەک file:///....
  • چاوەڕوانیی ئەوەی لە لاپەڕەی داهاتوودا بهێڵێتەوە. و هەموو لە سەرەتاوە دەست پێدەکاتەوە. بۆ لەبیرکردنی شتەکان یان بەکار بهێنە.
  • وا بزانیت یەک هەموو لاپەڕەکە هەڵدەگرێت. لە یەک دێت؛ هەر فایلێکی ، وێنە و تایبەتی خۆی دەوێت.
  • وا بزانیت 404 لە کۆدی . 404 Not Found واتە هیچ فایلێکی لەو نەدۆزییەوە: ناوی فایلەکە، و بپشکنە. لە جیاتی ئەوە 500 یان پەیامی دەدات.
  • ناردنی بە http://ـی سادە. هەر لاپەڕەیەک کە یان تێدا بێت دەبێت https:// بەکار بهێنێت.

Quick check and exercisesپشکنینی خێرا و ڕاهێنان

ExerciseڕاهێنانExercise 1: watch HTTP in your own browserڕاهێنانی ١: HTTP لە تۆڕگەڕەکەتدا ببینە

Open any website. Press F12 (or right-click and choose Inspect), open the Network tab, and reload the page (F5). Click the first line in the list. Find: (a) the request method, (b) the status code, (c) the Content-Type of the response. Then count how many requests the page needed in total.

هەر بکەرەوە. ⁦F12⁩ دابگرە (یان کرتەی ڕاست بکە و Inspect هەڵبژێرە)، تابی Network بکەرەوە و لاپەڕەکە نوێ بکەرەوە ⁦(F5)⁩. کرتە لە یەکەم دێڕی لیستەکە بکە. ئەمانە بدۆزەرەوە: (أ) ، (ب) ، (ج) Content-Typeـی . پاشان بژمێرە لاپەڕەکە بە گشتی پێویستی بە چەند بوو.

Show answerوەڵامەکە پیشان بدە

For a normal page you will see: (a) method GET, (b) status 200 (sometimes 301 or 304 if the page was moved or is already saved in the browser), (c) text/html; charset=UTF-8 or similar. The list usually has many lines, often dozens: one request for the HTML and one for every CSS file, picture, font and script. This is the "separate requests" step of the page load.

بۆ لاپەڕەیەکی ئاسایی دەبینیت: (أ) GET، (ب) دۆخی 200 (هەندێک جار 301 یان 304 ئەگەر لاپەڕەکە گوازرابێتەوە یان پێشتر لە هەڵگیرابێت)، (ج) text/html; charset=UTF-8 یان شتێکی هاوشێوە. لیستەکە زۆرجار چەندین دێڕی تێدایە، زۆرجار دەیان: بۆ و یەکێک بۆ هەر فایلێکی ، وێنە، فۆنت و . ئەمە هەنگاوی «»ی کردنەوەی لاپەڕەیە.

ExerciseڕاهێنانExercise 2: put the trail in orderڕاهێنانی ٢: ڕێچکەکە ڕێک بخە

These steps of the operational trail are mixed up. Put them in the right order: (a) Process PHP; (b) Return HTML; (c) the browser sends a request; (d) Apache finds hello.php; (e) the browser draws the page; (f) PHP reads data from the database.

ئەم هەنگاوانەی ڕێچکەی کارکردن تێکەڵ بوون. بە دروستی ڕێکیان بخە: (أ) جێبەجێکردنی ؛ (ب) ناردنەوەی ؛ (ج) دەنێرێت؛ (د) hello.php دەدۆزێتەوە؛ (هـ) لاپەڕەکە دەکێشێت؛ (و) دراوە لە دەخوێنێتەوە.

Show answerوەڵامەکە پیشان بدە

(c) → (d) → (a) → (f) → (b) → (e). The database step (f) happens while PHP is processing, and only if the page needs data.

(ج) ← (د) ← (أ) ← (و) ← (ب) ← (هـ). هەنگاوی (و) لە کاتێکدا ڕوودەدات کە کار دەکات و تەنها ئەگەر لاپەڕەکە پێویستی بە دراوە بێت.

ExerciseڕاهێنانExercise 3: what does the browser receive?ڕاهێنانی ٣: تۆڕگەڕ چی وەردەگرێت؟

Rezan saves this file as htdocs/today.php and opens http://localhost/today.php. Write exactly what the server sends to the browser, and what Rezan sees on the screen.

ڕێزان ئەم فایلە وەک htdocs/today.php پاشەکەوت دەکات و http://localhost/today.php دەکاتەوە. بە وردی بنووسە چی دەنێرێت بۆ و ڕێزان چی لەسەر شاشەکە دەبینێت.

today.phpPHPRuns on the serverلەسەر ڕاژەکاری وێب کار دەکات
<h2>Price list</h2>
<?php
$price = 500;
echo "<p>Tea: $price dinars</p>\n";
echo "<p>2 teas: " . (2 * $price) . " dinars</p>\n";
?>
Show answerوەڵامەکە پیشان بدە
What the server sendsئەوەی ڕاژەکار دەینێرێتHTML
<h2>Price list</h2>
<p>Tea: 500 dinars</p>
<p>2 teas: 1000 dinars</p>

The browser never receives $price, echo or the calculation 2 * $price: the server has already replaced them with their results.

هەرگیز $price، echo یان هەژمارکردنی 2 * $price وەرناگرێت: پێشتر ئەنجامەکانیانی لە جێیان داناوە.

ExerciseڕاهێنانExercise 4: stateless or not?ڕاهێنانی ٤: بێ‌دۆخ یان نا؟

Shilan adds three products to the shopping cart of an online shop, opens five other pages, and the cart still shows three products. HTTP is stateless, so how does the shop remember her cart?

شیلان سێ کاڵا دەخاتە سەبەتەی کڕینی دوکانێکی ئۆنلاین، پێنج لاپەڕەی تر دەکاتەوە و سەبەتەکە هێشتا سێ کاڵا پیشان دەدات. ، کەواتە دوکانەکە چۆن سەبەتەکەی لە بیر دەمێنێت؟

Show answerوەڵامەکە پیشان بدە

Not with HTTP itself. The shop stores the cart in a session on the server (or in a cookie in her browser). Her browser sends a cookie with a session ID in every request, so the server can find her cart each time.

بە خودی نا. دوکانەکە سەبەتەکە لە لەسەر هەڵدەگرێت (یان لە لە ). لە هەموو دەنێرێت کە تێدایە، بۆیە هەموو جارێک دەتوانێت سەبەتەکەی بدۆزێتەوە.

Summary and reviewکورتە و پێداچوونەوە

  • HTTP (HyperText Transfer Protocol) is the language browsers and servers use to ask for and send pages. HTTPS is the same, protected with encryption.
  • The client sends a request (method, path, headers); the server sends one response (status code, headers, body).
  • PHP is server-side: the browser asks for a .php page, the server runs the PHP code, and only HTML comes back.
  • The operational trail: request → Apache finds the page → PHP processes it (maybe with a database) → HTML is returned → the browser draws it.
  • After the HTML arrives, the browser builds the page, sends a separate request for each CSS file, picture and script, and finally runs the JavaScript.
  • HTTP is stateless: each request is independent. Websites remember users with cookies (on the client) and sessions (on the server).
  • ⁦(HyperText Transfer Protocol)⁩ ئەو زمانەیە کە و بۆ داواکردن و ناردنی لاپەڕەکان بەکاری دەهێنن. هەمان شتە، بە پارێزراو.
  • دەنێرێت (، ، )؛ یەک دەنێرێتەوە (، سەردێڕەکان، لاشە).
  • : داوای لاپەڕەیەکی .php دەکات، کۆدی جێبەجێ دەکات و تەنها دەگەڕێتەوە.
  • ڕێچکەی کارکردن: ← لاپەڕەکە دەدۆزێتەوە ← کاری لەسەر دەکات (لەوانەیە لەگەڵ ) ← دەنێردرێتەوە ← دەیکێشێت.
  • دوای گەیشتنی ، لاپەڕەکە دروست دەکات، بۆ هەر فایلێکی ، وێنە و جیا دەنێرێت و لە کۆتاییدا جێبەجێ دەکات.
  • : هەر سەربەخۆیە. بە (لە لای ) و (لەسەر ) بەکارهێنەران دەناسنەوە.
Review questionsپرسیارەکانی پێداچوونەوە
What are the client and the server in HTTP?ڕاژەخواز و ڕاژەکار لە HTTPـدا چین؟

The client (usually a web browser) sends requests; the server answers each request with one response.

(بە زۆری ) دەنێرێت؛ بە یەک هەر دەداتەوە.

Name the three main parts of an HTTP response.ناوی سێ بەشە سەرەکییەکەی وەڵامێکی HTTP بهێنە.

The status line (with the status code), the headers, and the body.

دێڕی دۆخ (لەگەڵ )، و لاشە.

Why can visitors never see your PHP code?بۆچی سەردانکەران هەرگیز کۆدی PHPـەکەت نابینن؟

Because the server runs it and sends only its HTML output. View Page Source shows that HTML, not the PHP.

چونکە جێبەجێی دەکات و تەنها دەنێرێت. ⁦View Page Source⁩ ئەو پیشان دەدات، نەک .

What does Apache do differently with about.html and hello.php?Apache چ جیاوازییەک لە نێوان about.html و hello.phpدا دەکات؟

It sends about.html exactly as it is. It gives hello.php to the PHP interpreter first and sends only the HTML output.

about.html هەروەک خۆی دەنێرێت. hello.php سەرەتا دەدات بە و تەنها دەنێرێت.

When does the server send an error response?ڕاژەکارەکە کەی وەڵامێکی هەڵە دەنێرێت؟

When it cannot find the page (404) or something else goes wrong (for example 500 for an error on the server).

کاتێک لاپەڕەکە نەدۆزێتەوە ⁦(404)⁩ یان شتێکی تر نادروست بڕوات (بۆ نموونە ⁦500⁩ بۆ لەسەر ).

Give one advantage and one disadvantage of HTTP being stateless.سوودێک و زیانێکی بێ‌دۆخ بوونی HTTP بڵێ.

Advantage: simpler servers and greater scalability. Disadvantage: extra work (cookies, sessions) to remember users across requests.

سوود: و فراوانبوونی زیاتر. زیان: کاری زیادە (، ) بۆ ناسینەوەی بەکارهێنەران لە نێوان .

Videoڤیدیۆ

Watch a videoسەیری ڤیدیۆیەک بکە

A video that viewers liked a lot and praised in their comments, chosen for this lesson.ڤیدیۆیەک کە بینەران زۆریان پێ خۆش بووە و لە کۆمێنتەکانیاندا ستایشیان کردووە، بۆ ئەم وانەیە هەڵبژێردراوە.

HTTP Crash Course & ExplorationTraversy Media · Englishئینگلیزی · 1.3M viewsبینین · 31K likesلایک · Partبەشی 1:25–11:36 (ofلە 38:30)

A clear tour of HTTP: why it is stateless, what HTTPS adds, methods like GET and POST, headers, and status codes.

گەشتێکی ڕوون بەناو : بۆچی ، چی زیاد دەکات، وەک GET و POST، و .

Watch 1:25–11:36, HTTP, stateless, HTTPS, methods, headers, status codes

لە ⁦1:25⁩ تا ⁦11:36⁩ سەیر بکە: بۆچی ، ، ، و .

Lesson complete!وانەکە تەواو بوو!

Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.

Key termsزاراوە سەرەکییەکان

Next lessonوانەی داهاتوو

Static and Dynamic Websites and Website Typesلاپەڕەتۆڕە نەگۆڕەکان، لاپەڕەتۆڕە داینامیکەکان و جۆرەکانی تۆڕگە

References and further readingسەرچاوەکان و خوێندنەوەی زیاتر

This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.