I'm always excited to take on new projects and collaborate with innovative minds.
+91 80824 84460
https://shahidmalla.com
Watergam, Baramulla Jammu and Kashmir
+91 80824 84460
Seekhiye kaysey third-party APIs ko apni PHP applications mein integrate karke powerful data access aur functionality hasil ki ja sakti hai

Tashreeh:
PHP ek server-side scripting language hai jisse web pages ko dynamic banaya jaata hai. Server par PHP code run hota hai aur HTML browser ko send ki jati hai.
Misalay (10 total: 5 real-life, 5 abstract)
(Real-Life) Home page par welcome message:
<?php echo "Meray Online Store mein Khush Aamdeed!"; ?>
(Real-Life) Aaj ka special product dikhana:
<?php
$specialProduct = "Organic Apples";
echo "Aaj ka special: $specialProduct";
?>
(Real-Life) Navigation menu ka dynamic hona:
<?php
$menuItems = ["Home","Shop","Contact"];
foreach($menuItems as $item) {
  echo "<a href='#'>$item</a> ";
}
?>
(Real-Life) Login ke baad user ka naam dikhana:
<?php
$userName = "Alice";
echo "Hello, $userName! Apke orders check karein?";
?>
(Real-Life) Footer mein saal dikhana:
<?php echo "© " . date("Y") . " Meri Company"; ?>
(Abstract) Simple number print:
<?php echo 2+3; ?>
(Abstract) String variable print karna:
<?php
$greeting = "Hello World";
echo $greeting;
?>
(Abstract) Conditional (har dafa run hoga):
<?php if(true){ echo "Ye hamesha chalay ga"; } ?>
(Abstract) Variable concatenation:
<?php
$city = "Paris";
echo "I love " . $city;
?>
(Abstract) PHP tags in HTML:
<html><body><?php echo "<h1>PHP Heading</h1>"; ?></body></html>
Tashreeh:
PHP code <?php ... ?> tag mein likha jata hai. Variables $ se shuru hotay hain. Case-sensitive hain.
Misalay (10 total: 5 real-life, 5 abstract)
(Real-Life) User ka email store karna:
$userEmail = "[email protected]";
echo "User Email: $userEmail";
(Real-Life) Price + Tax calculate karna:
$price = 100;
$tax = 0.08;
$total = $price + ($price*$tax);
echo "Total Price: $total";
(Real-Life) Cart mein items ki tadaad:
$cartCount = 3;
echo "Cart mein $cartCount items hain.";
(Real-Life) Delivery address show karna:
$deliveryAddress = "1234 Maple Street";
echo "Deliver hoga: $deliveryAddress";
(Real-Life) Discount code dikhana:
$discountCode = "SAVE20";
echo "Code $discountCode use karein 20% off k liye!";
(Abstract) Simple string var:
$msg = "Hello PHP";
echo $msg;
(Abstract) Integers add karna:
$x=10; $y=5;
echo $x+$y;
(Abstract) Variable update karna:
$counter=1;
$counter++;
echo $counter;
(Abstract) Strings concatenate:
$firstName="John"; $lastName="Doe";
echo $firstName." ".$lastName;
(Abstract) Double quotes mein variable:
$color="blue";
echo "Sky is $color";
Tashreeh:
PHP mein strings, integers, floats, booleans, arrays, objects aur NULL hotay hain. Type casting se ek type ko doosri type mein badla ja sakta hai.
Misalay (10 total: 5 real-life, 5 abstract)
(Real-Life) Product price float:
$productPrice = 19.99;
echo "Price: $$productPrice";
(Real-Life) Site visits integer:
$visits=120;
echo "Total visits: $visits";
(Real-Life) User login boolean:
$isLoggedIn = true;
if($isLoggedIn) { echo "Welcome back!"; }
(Real-Life) String se int cast (user input):
$quantity="5";
$quantityInt=(int)$quantity;
echo "Aap ne $quantityInt items select kiye.";
(Real-Life) Middle name NULL:
$middleName=null;
echo ($middleName===null)?"No middle name.":$middleName;
(Abstract) gettype():
$val=10;
echo gettype($val);
(Abstract) float to int cast:
$num=3.14;
echo (int)$num;
(Abstract) is_string() check:
$test="Hello";
if(is_string($test)){ echo "It's a string!"; }
(Abstract) is_null() check:
$x=null;
echo is_null($x)?"Null hai":"Null nahin";
(Abstract) boolean to string:
$flag=true;
echo (string)$flag; // "1"
Tashreeh:
Strings characters ka silsila hain. Common operations: concatenate, length check, uppercase, replace etc.
Misalay (10 total: 5 real-life, 5 abstract)
(Real-Life) User ka naam format karna (capitalize):
$first="john"; $last="doe";
$fullName=ucfirst($first)." ".ucfirst($last);
echo $fullName;
(Real-Life) Product title mein keyword dhoondhna:
$title="Organic Apple Juice";
if(strpos($title,"Apple")!==false){ echo "Apple included!"; }
(Real-Life) User input trim karna:
$input="   iphone   ";
echo trim($input);
(Real-Life) Email mask karna:
$email="[email protected]";
$masked=substr($email,0,3)."****".strstr($email,"@");
echo $masked;
(Real-Life) Description uppercase:
$desc="fresh organic apples";
echo strtoupper($desc);
(Abstract) strlen():
echo strlen("Hello World");
(Abstract) substr():
echo substr("Hello World",0,5);
(Abstract) str_replace():
echo str_replace("World","PHP","Hello World");
(Abstract) explode string to array:
$words=explode(" ","Split this");
print_r($words);
(Abstract) implode array to string:
$parts=["Join","me","now"];
echo implode("-",$parts);
Tashreeh:
Arithmetic (+ - * / %), comparison (== === != > <), logical (&& || !), concatenation (.) operators use hote hain.
Misalay (10 total: 5 real-life, 5 abstract)
(Real-Life) Total order price calculate karna:
$price=50; $qty=2;
echo $price*$qty; //100
(Real-Life) Free shipping threshold check:
$total=120;
if($total>=100){echo "Free shipping!";}
(Real-Life) Age check for signup:
$age=17;
echo ($age>=18)?"Sign up":"Underage";
(Real-Life) Promo code exact check:
$promo="SAVE10";
if($promo==="SAVE10"){echo "Promo applied!";}
(Real-Life) Stock zero check:
$stock=0;
if($stock==0){echo "Out of stock.";}
(Abstract) addition:
echo 3+7;
(Abstract) == vs ===:
$a="5";$b=5;
echo ($a==$b)?"Equal":"Not Equal"; //Equal
echo ($a===$b)?"Identical":"Not Identical"; //Not Identical
(Abstract) Logical AND:
if(10>0 && 5>0){echo "Both positive";}
(Abstract) Logical OR:
$color="red";
if($color=="red"||$color=="blue"){echo "Primary color";}
(Abstract) Remainder:
echo 10%3; //1
Tashreeh:
if/else conditions logic ko branch karte hain. switch multiple conditions ko handle karta hai.
Misalay (10 total: 5 real-life, 5 abstract)
(Real-Life) Admin check:
$role="admin";
if($role=="admin"){echo "Welcome admin!";}
(Real-Life) Discount apply ya nahin:
$total=200;
if($total>100){echo "Discount applied!";}else{echo "No discount.";}
(Real-Life) Payment method switch:
$payment="credit_card";
switch($payment){
  case "credit_card": echo "Credit card process..."; break;
  case "paypal":echo "PayPal process..."; break;
  default:echo "Not supported.";
}
(Real-Life) Location based delivery:
$location="International";
if($location=="Local"){echo "2 days delivery";}else{echo "International shipping";}
(Real-Life) Subscription level check:
$sub="gold";
if($sub=="gold"){echo "Premium features unlocked!";}
(Abstract) Simple if:
$x=5;if($x>0){echo "Positive";}
(Abstract) if/else:
$y=10;
if($y>10){echo "Greater";}else{echo "Not greater";}
(Abstract) if/elseif/else:
$num=0;
if($num>0){echo "Positive";}elseif($num<0){echo "Negative";}else{echo "Zero";}
(Abstract) Switch with color:
$c="blue";
switch($c){case"red":echo"Red";break;case"blue":echo"Blue";break;default:echo"Other";}
(Abstract) Nested if:
$a=4;if($a>0){if($a<5){echo"Between 1-4";}}
Tashreeh:
Loops repeat code blocks. foreach arrays k liye, for aur while condition based iteration k liye use hotay hain.
Misalay (10 total: 5 real-life, 5 abstract)
(Real-Life) Top-selling products list:
$products=["Laptop","Phone","Tablet"];
foreach($products as $p){echo $p."<br>";}
(Real-Life) Sale start countdown:
$days=5;
while($days>0){echo "Sale in $days days<br>";$days--;}
(Real-Life) Order IDs print:
$orderIds=[1001,1002,1003];
foreach($orderIds as $id){echo "Order ID: $id<br>";}
(Real-Life) Stock levels show:
$inventory=["Apple"=>50,"Banana"=>0];
foreach($inventory as $item=>$qty){echo "$item: $qty<br>";}
(Real-Life) Subscribers ko reminder:
$emails=["[email protected]","[email protected]"];
for($i=0;$i<count($emails);$i++){echo "Reminder to: ".$emails[$i]."<br>";}
(Abstract) Simple for:
for($i=1;$i<=5;$i++){echo $i;}
(Abstract) while loop:
$x=1;while($x<=3){echo$x;$x++;}
(Abstract) do-while:
$y=0;do{echo$y;$y++;}while($y<3);
(Abstract) foreach array:
$arr=[10,20,30];
foreach($arr as $val){echo$val;}
(Abstract) break loop:
for($i=0;$i<10;$i++){if($i==5)break;echo$i;}
Tashreeh:
Arrays multiple values store karte hain. Associative arrays keys ke sath. Multidimensional arrays arrays ke andar array.
Misalay (10 total: 5 real-life, 5 abstract)
(Real-Life) Product names list:
$products=["Keyboard","Mouse","Monitor"];
echo $products[0];
(Real-Life) Product prices associative:
$prices=["Keyboard"=>29.99,"Mouse"=>9.99];
echo $prices["Mouse"];
(Real-Life) Users data multidimensional:
$users=[["name"=>"Alice","email"=>"[email protected]"],["name"=>"Bob","email"=>"[email protected]"]];
echo $users[1]["email"];
(Real-Life) Categories and products:
$categories=["Fruits"=>["Apple","Banana"],"Veg"=>["Carrot","Lettuce"]];
echo $categories["Fruits"][0];
(Real-Life) Shopping cart (item=>qty):
$cart=["item1"=>2,"item2"=>3];
echo $cart["item1"];
(Abstract) Simple array:
$nums=[1,2,3];
echo $nums[2];
(Abstract) Add element:
$arr=[];$arr[]="Hello";print_r($arr);
(Abstract) count array elements:
$arr=["A","B","C"];
echo count($arr);
(Abstract) array_merge():
$a1=[1,2];$a2=[3,4];
print_r(array_merge($a1,$a2));
(Abstract) in_array():
$colors=["red","green","blue"];
if(in_array("green",$colors)){echo"Found green";}
Tashreeh:
Functions reusable code blocks hain. Parameters le sakti hain, value return kar sakti hain.
Misalay (10 total: 5 real-life, 5 abstract)
(Real-Life) Tax ke sath total:
function totalWithTax($price){$tax=0.08;return$price+($price*$tax);}
echo totalWithTax(100);
(Real-Life) Full name format:
function formatName($f,$l){return ucfirst($f)." ".ucfirst($l);}
echo formatName("jane","doe");
(Real-Life) Stock check function:
function isInStock($qty){return$qty>0;}
echo isInStock(5)?"In stock":"Out";
(Real-Life) Welcome message:
function welcomeMessage($user){return"Hello $user";}
echo welcomeMessage("Alice");
(Real-Life) Apply discount coupon:
function applyDiscount($total,$code){if($code=="SAVE10"){return$total*0.9;}return$total;}
echo applyDiscount(200,"SAVE10");
(Abstract) Simple add:
function add($a,$b){return$a+$b;}
echo add(2,3);
(Abstract) No return function:
function greet(){echo"Hello!";}
greet();
(Abstract) Default parameter:
function multiply($a,$b=2){return$a*$b;}
echo multiply(5);
(Abstract) Array as argument:
function printArray($arr){foreach($arr as $i){echo $i." ";}}
printArray(["X","Y","Z"]);
(Abstract) Type declarations:
function sumIntegers(int$x,int$y):int{return$x+$y;}
echo sumIntegers(4,5);
Tashreeh:
Forms se data GET/POST mein aata hai. $_GET aur $_POST se access karein, phir sanitize karein.
Misalay (10 total: 5 real-life, 5 abstract)
(Real-Life) Login form process (POST):
if($_SERVER['REQUEST_METHOD']==='POST'){
  $username=$_POST['username'];
  echo "Welcome, $username";
}
(Real-Life) Product search (GET):
$query=$_GET['q']??'';
echo "Search: $query";
(Real-Life) Contact form input sanitize:
$name=htmlspecialchars($_POST['name']);
$msg=htmlspecialchars($_POST['message']);
echo "Shukriya $name, message received.";
(Real-Life) Dropdown category:
$category=$_POST['category'];
echo "Selected: $category";
(Real-Life) File upload:
if(isset($_FILES['image'])){
  move_uploaded_file($_FILES['image']['tmp_name'],"uploads/".$_FILES['image']['name']);
  echo "File uploaded!";
}
(Abstract) Default GET page:
$page=$_GET['page']??1;
echo "Page: $page";
(Abstract) Form submitted check:
if(!empty($_POST)){echo"Form submitted!";}
(Abstract) filter_var():
$data=filter_var($_POST['data'],FILTER_SANITIZE_STRING);
echo $data;
(Abstract) Validate integer:
$num=filter_input(INPUT_GET,'num',FILTER_VALIDATE_INT);
if($num!==false){echo"Valid number";}
(Abstract) Empty field check:
$field=$_POST['field']??'';
if(trim($field)==''){echo"Field empty";}
Tashreeh:$_GET aur $_POST form data hold karte hain. $_SERVER server info deta hai.
Misalay (10 total: 5 real-life, 5 abstract)
$_GET['product_id'] se product page load$_POST['password'] login ke liye$_SERVER['HTTP_USER_AGENT'] browser detect karne ke liye$_SERVER['REMOTE_ADDR'] se user IP log karna$_SERVER['REQUEST_METHOD'] se pata GET/POST$_GET['page'] pagination ke liye$_POST['comment'] feedback form$_SERVER['PHP_SELF'] current script ka naam$_SERVER['SERVER_NAME'] server ka naam$_SERVER['REQUEST_URI'] request pathTashreeh:
Session server par data store karta hai, cookies client browser mein. Dono se user state maintain ki jati hai.
Misalay (10 total: 5 real-life, 5 abstract)
session_start(); $_SESSION['count']=1;isset($_SESSION['count'])setcookie("name","value",time()+3600);Tashreeh:
Files read/write, upload aur delete kiye ja sakte hain.
Misalay (10 total: 5 real-life, 5 abstract)
fopen(), fread(), fclose()file_get_contents("file.txt")file_put_contents("file.txt","Hello")file_exists("file.txt") checkunlink("file.txt") deleteTashreeh:
JSON data exchange ke liye common hai. json_encode() aur json_decode() use hotay hain.
Misalay (10 total: 5 real-life, 5 abstract)
json_encode(["a"=>1,"b"=>2])json_decode('{"x":10,"y":20}',true)json_last_error() check karnaJSON_PRETTY_PRINTTashreeh:date() aur DateTime classes time handle karte hain. Format, timezone change, calculations sab mumkin.
Misalay (10 total: 5 real-life, 5 abstract)
date("Y-m-d") current datedate("H:i:s") current timeDateTime object use karnadate("F j, Y")time() current timestampTashreeh:
try/catch blocks exceptions handle karte hain. error_reporting() error levels set karta hai.
Misalay (10 total: 5 real-life, 5 abstract)
try{...}catch(Exception$e){...}throw new Exception("Error")error_reporting(E_ALL); sab errorsset_error_handler() custom handlerfinally block cleanup ke liyeTashreeh:
OOP classes, objects, properties, methods, inheritance, interfaces use karta hai. Yeh code ko structured banata hai.
Misalay (10 total: 5 real-life, 5 abstract)
class Product {public $name;...} product ko represent karnaclass User {private $email;...} user data encapsulate karnaclass ShoppingCart addItem(), getTotal() methodsclass Order placeOrder() methodclass PaymentGateway interface implement karnaclass MyClass{} aur new MyClass()class Child extends Parentinterface MyInterface{} implement karna__construct() initializationstatic properties/methodsTashreeh:
Namespaces classes ko organize karte hain. Autoloading se require bar bar nahi karna parta.
Misalay (10 total: 5 real-life, 5 abstract)
namespace App\Controllers; class HomeController{}App\Models, App\Views mein classes organize karnarequire "vendor/autoload.php";use App\Models\User;composer dump-autoload run karnanamespace MyProject; file ke start meinTashreeh:
XSS se bachne ke liye output escape karein, SQL injection se bachne ke liye prepared statements, CSRF tokens use karein, passwords hash karein.
Misalay (10 total: 5 real-life, 5 abstract)
htmlspecialchars() user comments output pepassword_hash() user passwords ke liyefilter_var() input validationTashreeh:
PDO se MySQL connect karo, queries run karo, results fetch karo.
Misalay (10 total: 5 real-life, 5 abstract)
$pdo=new PDO("mysql:host=localhost;dbname=test","user","pass");$stmt=$pdo->query("SELECT * FROM table");$row=$stmt->fetch(PDO::FETCH_ASSOC);$stmt->execute() prepared statements ke sathTashreeh:
Prepared statements SQL injection se bachate hain. Data aur query ko separate rakhte hain.
Misalay (10 total: 5 real-life, 5 abstract)
SELECT * FROM users WHERE email=?INSERT INTO products(name,price)VALUES(?,?)UPDATE inventory SET qty=? WHERE id=?LIKE ?$stmt=$pdo->prepare("...")$stmt->bindParam(...)$stmt->bindValue(...)$results=$stmt->fetchAll()$stmt->rowCount()Tashreeh:
Composer dependency manager hai. composer.json mein libraries define karein, composer require se install.
Misalay (10 total: 5 real-life, 5 abstract)
composer require stripe/stripe-php payment librarycomposer update dependencies update karnacomposer initcomposer installrequire "vendor/autoload.php"; code meincomposer dump-autoloadTashreeh:
Laravel jaise frameworks MVC structure, routing, ORM dete hain, jisse development tez aur organized ho jati hai.
Misalay (10 total: 5 real-life, 5 abstract)
Route::get('/products',...) routingphp artisan make:controller ProductControllerProduct::all()php artisan serve local server.env file mein DB credentialsphp artisan test unit testingTashreeh:
RESTful APIs JSON data return karti hain. cURL ya Guzzle se external APIs consume kiye ja sakte hain.
Misalay (10 total: 5 real-life, 5 abstract)
header('Content-Type: application/json');echo json_encode($responseArray);file_get_contents("http://api.example.com")curl_init(), curl_setopt(), curl_exec()json_decode() API response parse karnaTashreeh:
Design patterns se code maintainable banta hai. Caching (APCu, Redis) se performance behter. Profiling aur optimization zaroori hai.
Misalay (10 total: 5 real-life, 5 abstract)
apcu_store() aur apcu_fetch() cache ke liyexhprofOPcache se PHP scripts cache karnaYour email address will not be published. Required fields are marked *