Web preparation Flashcards

(32 cards)

1
Q

What are differences between back-end and front-end? Explain

A
  • Front-end គឺជាផ្នែកដែលអ្នកប្រើប្រាស់អាចមើលឃើញ និងអន្តរកម្មដោយផ្ទាល់ (UI)។ វាប្រើ HTML, CSS, និង JavaScript។
  • Back-end គឺជាផ្នែកនៅក្រោយដែលដំណើរការទិន្នន័យ និងសេវាកម្ម។ វាប្រើភាសាដូចជា PHP ជាដើម។
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are differences between static website and dynamic website?

A
  • Static Website គេហទំព័រមិនផ្លាស់ប្តូរទ្រង់ទ្រាយ ឬមាតិកា។ គេអាចសរសេរជា HTML ផ្ទាល់។
  • Dynamic Website មានការផ្លាស់ប្តូរមាតិកាផ្អែកលើអ្នកប្រើប្រាស់។ ប្រើភាសាដូចជា PHP, JavaScript និងតម្រូវឲ្យមាន database។
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How many languages that we can use to build dynamic websites?

A

មានភាសាច្រើនដែលអាចប្រើបាន៖ PHP, Python (Django/Flask), Ruby (Rails), Java (Spring), Node.js, ASP.NET, Perl, Go និងអាចប្រើរួមជាមួយ JavaScript (React, Vue, Angular) ។

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain about the processes of web-client and web-server when we open a website

A
  1. Client (browser) ផ្ញើ HTTP Request ទៅ Server
  2. Server ដំណើរការទៅតាម Request
  3. Server ផ្ញើមកវិញ Response (HTML, JSON, ឬអ្វីផ្សេងទៀត)
  4. Client(browser)​ បង្ហាញលទ្ធផល
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is PHP? What are the advantages and disadvantages of using PHP?

A

PHP គឺជាភាសា server-side scripting សម្រាប់បង្កើត dynamic website។
* អត្ថប្រយោជន៍៖ ងាយស្រួលសិក្សា, មាន Framework ច្រើន (Laravel), ទទួលបាននូវជំនួយពី community យ៉ាងខ្លាំងក្លា
* គុណវិបត្តិ៖ អាចមានប្រសិទ្ធិភាពទាបប្រសិនបើសរសេរមិនបានល្អ ឬ ត្រឹមត្រូវ។

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the different between web dynamic client and web dynamic server?

A
  • Dynamic Client (ជាឧទាហរណ៍ ReactJS): កែប្រែ UI ខាងមុខដោយ JavaScript ទៅតាមទិន្នន័យ
  • Dynamic Server: កែប្រែទិន្នន័យនៅ server ដោយប្រើ PHP ដើម្បីបង្កើត HTML ឬ JSON Response
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Model View Control (MVC)? Explain each of them

A
  • Model៖ គ្រប់គ្រងទិន្នន័យ និង database
  • View៖ ផ្នែកបង្ហាញ UI
  • Controller៖ ទទួលសំណើពី client ហើយផ្ញើទៅ model ឬ view
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain about the benefit of using MVC in web development

A
  • បែងចែកដាច់នូវមុខងារ UI, Data, និង Logic
  • ងាយស្រួលក្នុងការ Maintenance
  • Reuse code
  • កែលំអរការប្រើប្រាស់សហការគ្នារវាង Developer និង Developer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In MVC pattern of laravel, explain the process when user visits our website.

A
  1. User វាយ URL
  2. Route ទៅកាន់ Controller
  3. Controller យកទិន្នន័យពី Model
  4. Controller ផ្ញើទៅ View
  5. View បង្ហាញទៅអ្នកប្រើប្រាស់
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How many variable scopes in PHP? List all of them with examples

A
  1. Local – នៅក្នុង function
    example: https://drive.google.com/file/d/1iZhutzDpqx9mac28jBZxM53jiQEG_kHS/view?usp=sharing
  2. Global – នៅក្រៅ function
    example: https://drive.google.com/file/d/102sa529n9OLwl7VlnhTjYQEjrUk6oA1K/view?usp=sharing
  3. Static – រក្សានូវរម្លៃរបស់ខ្លួននៅពេលដែលមានការហៅយកទៅប្រើប្រាស់
    example: https://drive.google.com/file/d/1ZL1zNm_DgYAgLyEiEM_xQfF1Lg93c4jh/view?usp=sharing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain about “global” and “static” keywords in PHP with examples

A
  • global៖ ប្រើសម្រាប់ចូលដំណើរការក្នុងប្រព័ន្ធដែលប្រែប្រួលនៅក្រៅ function។
    ឧទាហរណ៌៖
    $x = 5;
    function test() {
    global $x;
    echo $x;
    }
  • static៖ ប្រើសម្រាប់រក្សាតម្លៃប្រែប្រួលក្នុង function រាល់ការហៅ។
    ឧទាហរណ៌៖
    function counter() {
    static $i = 0;
    $i++;
    echo $i;
    }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the different between “echo” and “print”? Give examples about how to use them

A
  • echo៖ បង្ហាញអត្ថបទ ឬ multiple value, មានល្បឿនលឿន
    echo “Hello”, “ World!”;
  • print៖ បង្ហាញអត្ថបទ តែតម្លៃតែ១ប៉ុណ្ណោះ
    print “Hello World!”;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the differences between $_POST and $_GET? Give examples

A
  • $_GET៖ ទាញទិន្នន័យតាម URL
    ឧទាហរណ៌៖ https://drive.google.com/file/d/1HJlEjY3OTT4xyd64FCWGDvsrfGROzi9z/view?usp=sharing
  • $_POST៖ ទាញពី form ដោយមិនបង្ហាញក្នុង URL
    ឧទាហរណ៌៖ https://drive.google.com/file/d/1k358gF3XlamAcFhR4OWRwo7CY4o5Zx5D/view?usp=sharing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Write code PHP to allow upload multiple files (only image) to server

A

https://drive.google.com/file/d/1UDPQkLZCEXKOzq88fWnPeyvsC8FYkJnH/view?usp=sharing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the differences between cookies and session? Give example

A
  • Cookie៖ រក្សាទុកនៅ Client
    ឧទាហរណ៌៖ setcookie(“user”, “Vakhim”, time()+3600);
  • Session៖ រក្សាទុកនៅ Server
    ឧទាហរណ៌៖ $_SESSION[‘user’] = “Vakhim”;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Can cookie and session store the binary file? Explain

A

ទេ! ពួកវាមានគោលបំណងរក្សាទុកតែ string ឬ primitive types ដូចជា text, id,… មិនសមស្របសម្រាប់ binary file។

17
Q

Write PHP code to generate the random number with 8 digit (only number)

A

echo rand(10000000, 99999999);

18
Q

Write PHP code to write “Hello World!” 1000 line in a file named myfile.txt

A

https://drive.google.com/file/d/1CyBj-4ZK8gA-OCdki3J0nlEQDr5pr6nh/view?usp=sharing

19
Q

Write 3 functions to connect, insert, update, and delete data from mysql database respectively

A

$conn = connect();

https://drive.google.com/file/d/1RYREgi_z6ihaEhEQnIC8L-uSsRYZjudG/view?usp=sharing

20
Q

What is the difference between $var1 and $$var1?

A
  • $var1 = “hello”;
  • $$var1 = “world”; → បង្កើត variable $hello = “world”
21
Q

What are the ways to define a constant in PHP?

A

define(“GREETING”, “Welcome to RUPP!”);

const NAME = “LOLA”;

22
Q

What does isset() function?

A

ពិនិត្យមើលថាប្រែប្រួលត្រូវបានកំណត់ឬអត់

if (isset($name)) {
echo $name;
}

23
Q

What is $_SERVER? Explain about the benefit of using this variable

A

រក្សាទិន្នន័យបណ្តាញដូចជា IP, URI, Server Name

echo $_SERVER[‘REMOTE_ADDR’];
ទទួលព័ត៌មានអំពីអ្នកប្រើប្រាស់ (Client)

echo $_SERVER[‘REQUEST_URI’];
កំណត់ផ្លូវនៃ folder

echo $_SERVER[‘HTTP_HOST’];
ចាប់ Domain ឬ Host Name

echo $_SERVER[‘REQUEST_METHOD’];
ដឹងពីប្រភេទសំណើ (GET/POST)

24
Q

What is the difference between require, require_once, include, include_once?

A
  • require: បើមិនមាន file → បញ្ឈប់
  • include: បើមិនមាន file → បន្តដំណើរការ
  • require_once/include_once: បញ្ចូលតែ១ដង
25
What is the difference between mysqli and PDO, and when would you use one over the other?
* mysqli: ជាប្រភេទ procedural និង OOP → support MySQL only * PDO: support DB ជាច្រើន, OOP friendly, better security
26
What is object-oriented programming (OOP), and how do you create classes and objects in PHP to organize code and improve code reuse?
Object-Oriented Programming (OOP) គឺជាវិធីសាស្ត្រនៃការសរសេរកូដដែលផ្អែកលើ (Object) ដែលបង្កើតចេញពី (Class)។ វាអនុញ្ញាតឱ្យអ្នកអាចរៀបចំកូដបានល្អ និងអាចប្រើឡើងវិញបានយ៉ាងមានប្រសិទ្ធភាព។ https://drive.google.com/file/d/18lhz8V7KUr_vAIXVFxod0XZeNSv3B2Ak/view?usp=sharing
27
How can we create a database named “mydatabase” using PHP and MySQL?
$conn = new mysqli("localhost", "root", ""); $conn->query("CREATE DATABASE mydatabase");
28
Write a PHP code to send an email
mail("test@example.com", "Subject", "Hello from PHP!");
29
How can you execute SQL queries in PHP, and what are some best practices for handling user input to prevent SQL injection attacks?
Execute SQL queries: https://drive.google.com/file/d/1_Nz06KtIYro3hHcIUxJFkVrIQE-QoFzE/view?usp=sharing Best practices to prevent SQL injection: https://drive.google.com/file/d/1e1hxuldi1EOfBXYKyVK63a7a__ikyiXD/view?usp=sharing
30
Write a code let user upload only image to server and the image must less than 3MB
https://drive.google.com/file/d/1oKU6Fa56Ji2RqiRlVypfnJZDO8Gl_kOc/view?usp=sharing
31
Write a php to connect to database and insert a data to database below: https://drive.google.com/file/d/1e4h5x2GVy1c0iYpZ2IEgNvTe7c7jt402/view?usp=sharing
https://drive.google.com/file/d/1jJJloqMHZIpPKT_ljm3TCo10XQ2RV4AY/view?usp=sharing
32
Write to search for a student based on their name and date of birth in a single php file. If the student is found, “Found!” message will be display while if not, “Not Found!” message is shown in the page.
https://drive.google.com/file/d/1ZYwWpGWcSAzBc_zKl4sflvprbRLavzaP/view?usp=sharing