सभी tools
निःशुल्क

एक खोजने योग्य, प्रिंट करने योग्य PHP 8.3+ संदर्भ — सिंटैक्स, स्ट्रिंग, ऐरे, फंक्शन, क्लास, enums, एट्रिब्यूट और आधुनिक सुविधाएँ। मुफ्त।

मूल बातें और टाइप

10
declare(strict_types=1);
सख्त scalar टाइप जाँच लागू करें
$x = 1;
वेरिएबल डॉलर चिह्न से शुरू होते हैं
const MAX = 100;
Compile-time constant
gettype($x)
मान का टाइप प्राप्त करें
(int) $x
integer में cast करें
is_int($x)
टाइप-जाँच हेल्पर (is_string, ...)
int|string $x
Union टाइप घोषणा
?string $x
Nullable टाइप (string या null)
$a ?? 'default'
Null coalescing operator
$a ??= 'default'
केवल null होने पर असाइन करें

Strings

11
"Hello $name"
Double quotes वेरिएबल इंटरपोलेट करते हैं
'literal $x'
Single quotes literal होते हैं
$a . $b
strings जोड़ें
strlen($s)
string की byte लंबाई
str_contains($s, 'a')
substring की जाँच करें
str_starts_with($s, 'a')
prefix जाँचें
substr($s, 0, 3)
string का एक भाग निकालें
str_replace('a', 'b', $s)
सभी घटनाएँ बदलें
explode(',', $s)
array में विभाजित करें
sprintf('%05.2f', $n)
फ़ॉर्मेटेड string आउटपुट
trim($s)
आसपास का whitespace हटाएँ

Arrays

11
$a = [1, 2, 3];
Indexed array literal
$a = ['k' => 'v'];
Associative array
array_map(fn($x) => $x * 2, $a)
प्रत्येक element को रूपांतरित करें
array_filter($a, fn($x) => $x > 0)
मेल खाने वाले elements रखें
array_reduce($a, $fn, 0)
एकल मान में घटाएँ
in_array($v, $a, true)
सख्त मान जाँच
array_keys($a)
सभी keys प्राप्त करें
array_merge($a, $b)
arrays मर्ज करें
[...$a, ...$b]
arrays spread/मर्ज करें
count($a)
elements की संख्या
[$x, $y] = $a;
Array destructuring

फंक्शन

9
function f(int $a): int {}
टाइप किए parameters और return
function f(int $a = 1) {}
डिफ़ॉल्ट parameter मान
function f(int ...$nums) {}
Variadic parameters
f(...$args)
arguments spread करें
f(name: 'Sam', age: 30)
नामित arguments
$fn = fn($x) => $x + 1;
Arrow function (स्कोप स्वतः कैप्चर करता है)
function () use ($x) {}
वेरिएबल कैप्चर करने वाला closure
$fn = strlen(...);
First-class callable सिंटैक्स
function f(): never {}
कभी return नहीं करता (throw या exit)

Control flow

9
if ($a) {} elseif ($b) {} else {}
सशर्त शाखाएँ
$a ? $b : $c
Ternary एक्सप्रेशन
$a ?: $b
शॉर्ट ternary (falsy fallback)
match ($x) { 1, 2 => 'a', default => 'b' }
सख्त, एक्सप्रेशन-आधारित match
switch ($x) { case 1: break; }
ढीली बहु-मार्गी शाखा
foreach ($a as $k => $v) {}
keys और values पर इटरेट करें
for ($i = 0; $i < 10; $i++) {}
गिनती वाला loop
while ($cond) {}
जब तक शर्त सही है तब तक loop करें
break / continue
loop इटरेशन से बाहर निकलें या छोड़ें

Classes और OOP

10
class A extends B implements C {}
इनहेरिटेंस और interfaces
public function __construct(private int $id) {}
Constructor property promotion
public readonly string $name;
इनिशियलाइज़ेशन के बाद immutable
public function f(): static {}
late-bound टाइप लौटाएँ
static::create()
Late static binding
$obj?->method()
Null-safe method कॉल
abstract class A {}
सीधे instantiate नहीं किया जा सकता
trait T {} use T;
पुन: उपयोग योग्य क्षैतिज कोड
$obj instanceof A
runtime पर टाइप जाँच
A::class
पूर्ण-योग्य class नाम string

Enums

9
enum Status { case Active; case Draft; }
Pure enumeration
enum Status: string { case A = 'a'; }
Backed enum (string/int)
Status::Active
enum case का संदर्भ दें
Status::from('a')
backing मान से बनाएँ
Status::tryFrom('x')
अमान्य होने पर null लौटाता है
Status::cases()
सभी cases का array
$status->value
किसी case का backing मान
$status->name
case का नाम
enum E { public function label() {} }
Enums में methods हो सकते हैं

Error handling

9
try {} catch (Throwable $e) {}
errors और exceptions पकड़ें
catch (TypeError | ValueError $e)
कई टाइप पकड़ें
catch (Exception)
गैर-कैप्चरिंग catch (कोई वेरिएबल नहीं)
finally {}
try/catch के बाद हमेशा चलता है
throw new RuntimeException('x')
exception throw करें
throw $e;
पकड़े गए exception को फिर से throw करें
$x = $v ?? throw new Error();
एक्सप्रेशन के रूप में throw करें
$e->getMessage()
error संदेश पढ़ें
$e->getPrevious()
चेन किया गया exception प्राप्त करें

Attributes और आधुनिक

9
#[Attribute] class Route {}
कस्टम attribute घोषित करें
#[Route('/home')]
किसी target पर attribute लागू करें
new ReflectionClass($x)
reflection के माध्यम से class का निरीक्षण करें
$ref->getAttributes()
घोषित attributes पढ़ें
json_encode($data)
JSON में सिरियलाइज़ करें
json_decode($s, true)
JSON को array में डिकोड करें
array_is_list($a)
true यदि keys क्रम में 0..n हैं
str_word_count($s)
string में शब्द गिनें
$obj::class
instance से class नाम

कोई प्रविष्टि “:q” से मेल नहीं खाती।


इसे साझा करें
मदद चाहिए?
इस टूल में कोई समस्या मिली? हमारी टीम को बताएं।
समस्या की रिपोर्ट करें

इस मुफ़्त टूल को अपनी वेबसाइट पर जोड़ें — नीचे दिया गया कोड कॉपी और पेस्ट करें।