⊗ppSpAiGP 43 of 83 menu

API With GET Parameter in PHP

Let's now make an API that will receive a parameter when accessed, and the response will be given depending on this parameter.

For example, let an integer be passed as a parameter:

http://api.loc/index.php?num=100

Let's return a random number in the range from one to the passed number in response:

<?php if (isset($_GET['num'])) { echo mt_rand(1, $_GET['num']); } else { echo 'error'; } ?>

Create an API with an address, to which a date in the format year-month-day will be passed as a parameter, and in response the day of the week corresponding to that date will be returned.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline