Ví dụ api php

Tôi cần gửi cho một số dữ liệu để nghỉ dịch vụ web. Tôi đã cố gắng mô phỏng API phụ trợ đó hoạt động chính xác nhưng tôi không biết cách cấp quyền cho API đó thông qua tiêu đề

Nội dung chính Hiển thị

  • Các tiêu đề trong ví dụ API REST là gì?
  • Chúng ta có thể viết API REST trong PHP không?
  • Tiêu đề trong API REST là gì?
  • API trong PHP với ví dụ là gì?

Trong tiêu đề nên có một.

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
1 được đặt vào
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
2

Đây là những gì tôi đã thử nhưng không thành công

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$data = json_encode($arr);
$token = "ThisIsSomeLongToken";

header("POST ".$path." HTTP/1.1\r\n");
header("Host: ".$host."\r\n");
header("Content-type: application/json\r\n");
header("Authorization: Bearer ".$token." \r\n");
header("Content-length: " . strlen($data) . "\r\n");
header("Connection: close\r\n\r\n");
header($data);

Tôi là người mới trong các dịch vụ web PHP vì vậy tôi thậm chí không biết điều này có đúng không nhưng nó không gây ra bất kỳ lỗi nào và cũng không làm gì với dịch vụ web

Tôi có thể hy vọng một số khách hàng tiềm năng trong API REST PHP với các tiêu đề không?

Hỏi ngày 11 tháng 8 năm 2015 lúc 11. 51 11 Tháng tám 2015 lúc 11. 51

Bạn không thể gửi yêu cầu POST bằng cách sử dụng chức năng

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
3. Bạn nên sử dụng
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
4 để điều đó. Tra cứu tài liệu tại đây. Điều này có thể sẽ làm những gì bạn muốn.
Điều này có thể sẽ làm những gì bạn muốn.

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);

Đã trả lời ngày 11 tháng 8 năm 2015 lúc 12. 02 11 Tháng tám 2015 lúc 12. 02

Ví dụ api php

Tháng 1. jjan. J Tháng 1. J

3. 0101 Huy hiệu vàng23 Huy hiệu bạc32 Huy hiệu đồng1 huy hiệu vàng23 huy hiệu bạc32 huy hiệu đồng

0

Xin chào Reddit,

Tôi đang xây dựng dự án đầu tiên của mình bằng Php và JavaScript, bằng cách thực hiện API REST để đăng và lấy dữ liệu từ cơ sở dữ liệu bằng PDO. Cho đến bây giờ, tôi đã sao chép tiêu đề () khi bắt đầu điểm cuối PHP vào tất cả các điểm cuối phù hợp (nghĩa là nhận được với Get và Post với bài đăng, luôn luôn cho JSON). Bây giờ, tôi đang tự hỏi liệu tôi có cần tất cả chúng có tính đến

  • Tôi đang lưu trữ trang web của mình trên máy chủ Apache2, có API trong cùng Vhost với Frontend của tôi, vì vậy tôi không cần CORS

  • Tôi chỉ xác thực JWT cho các yêu cầu POST và gửi nó qua tải trọng

Các đoạn trích tôi sao chép từng lần là. Nhận (JSON)

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
5

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
6

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
7

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
8

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
0

BÀI ĐĂNG (JSON)

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
5
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
6

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
3
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
8
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
0
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
6
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
3
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
8
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
0

Đăng (formData, để tải lên hình ảnh)

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
5

$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
7
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
3
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
8
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
10
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
7
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
3
_______08
$host = "www.example.com";
$path = "/path/to/backend";
$arr = array('caseNumber' => '456456787');
$token = "ThisIsSomeLongToken";

$ch = curl_init();

// endpoint url
curl_setopt($ch, CURLOPT_URL, $host . $path);

// set request as regular post
curl_setopt($ch, CURLOPT_POST, true);

// set data to be send
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr));

// set header
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Bearer: ' . $token));

// return transfer as string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);
10

Vì vậy, điều tôi muốn là loại bỏ tất cả những thứ tôi không cần và chắc chắn ứng dụng của mình nhiều nhất có thể. Nhưng tôi cảm thấy như tôi đã sao chép những thứ tôi không cần (đây là lần đầu tiên tôi xây dựng API REST) ​​và hơi lạc lõng và lo lắng về khả năng có một lỗ hổng bảo mật lớn mà ai có thể làm được.

Bất kỳ sự trợ giúp nào được đánh giá cao. Thank before

Các tiêu đề trong ví dụ API REST là gì?

Tiêu đề API giống như một nguồn thông tin bổ sung cho mỗi API gọi bạn thực hiện. Công việc của họ là đại diện cho siêu dữ liệu liên quan đến yêu cầu và phản hồi API. Nếu bạn từng gặp phải vấn đề với API, nơi đầu tiên bạn nên xem là các tiêu đề, vì chúng có thể giúp bạn theo dõi mọi vấn đề tiềm năng. nguồn thông tin bổ sung cho mỗi lệnh gọi API mà bạn thực hiện . Công việc của họ là đại diện cho siêu dữ liệu được liên kết với yêu cầu và phản hồi API. Nếu bạn từng gặp sự cố với API, thì nơi đầu tiên bạn nên xem xét là các tiêu đề, vì chúng có thể giúp bạn theo dõi bất kỳ sự cố tiềm ẩn nào.

Chúng ta có thể viết API REST trong PHP không?

Có nhiều khung tuyệt vời có thể giúp bạn xây dựng API REST một cách nhanh chóng. API nền tảng của Laravel/lum và Symfony là những ví dụ được sử dụng thường xuyên nhất trong hệ sinh thái PHP. Chúng tôi cung cấp các công cụ tuyệt vời để xử lý các yêu cầu và tạo các phản hồi JSON với mã trạng thái HTTP chính xác. Nền tảng API của Laravel/Lumen và Symfony là những ví dụ được sử dụng thường xuyên nhất trong hệ sinh thái PHP . Họ cung cấp các công cụ tuyệt vời để xử lý yêu cầu và tạo phản hồi JSON với mã trạng thái HTTP chính xác.

Tiêu đề trong API REST là gì?

Tiêu đề phản hồi cung cấp thông tin về trạng thái của yêu cầu và trả về thông tin ETAG. Phản hồi cũng bao gồm một mã trạng thái. Xác định HTTP một tập hợp các tiêu đề yêu cầu và tiêu đề phản hồi tiêu chuẩn. cung cấp thông tin về trạng thái của yêu cầu và trả về thông tin ETag . Phản hồi cũng bao gồm một mã trạng thái. HTTP xác định một tập hợp các tiêu đề yêu cầu và phản hồi tiêu chuẩn.

API trong PHP với ví dụ là gì?

Giao diện lập trình ứng dụng hoặc API, xác định các lớp, phương thức, chức năng và biến mà ứng dụng của bạn sẽ yêu cầu để thực hiện nhiệm vụ mong muốn của nó. Trong trường hợp các ứng dụng PHP cần giao tiếp với cơ sở dữ liệu, các API cần thiết thường được hiển thị thông qua các tiện ích mở rộng PHP. xác định các lớp, phương thức, hàm và biến mà ứng dụng của bạn sẽ cần gọi để thực hiện nhiệm vụ mong muốn