Azərbaycan ▾
Top | Yeni | Dərslər | Forum

Ən lazımlı PHP kodları

Forum › Ümumi müzakirə
💬 3 · 👁 3
mywap.az · 16.10.2026 00:47
<?php
$stmt = $pdo->prepare(
"SELECT id, title, price FROM listings
WHERE id = :id LIMIT 1"
);

$stmt->execute(['id' => (int) $_GET['id']]);
$listing = $stmt->fetch(PDO::FETCH_ASSOC);

if ($listing) {
echo htmlspecialchars(
$listing['title'],
ENT_QUOTES,
'UTF-8'
);
}
mywap.az · 16.10.2026 00:48
<?php
function e(?string $value): string
{
return htmlspecialchars(
$value ?? '',
ENT_QUOTES | ENT_SUBSTITUTE,
'UTF-8'
);
}
?>

<h2><?= e($listing['title'] ?? '') ?></h2>
mywap.az · 16.10.2026 00:48
<?php
function slugify(string $text): string
{
$text = mb_strtolower(trim($text), 'UTF-8');

$text = strtr($text, [
'ə' => 'e', 'ı' => 'i',
'ö' => 'o', 'ü' => 'u',
'ğ' => 'g', 'ş' => 's',
'ç' => 'c',
]);

$text = preg_replace('/[^a-z0-9]+/', '-', $text) ?? '';
return trim($text, '-');
}

echo slugify('BMW X5 E53 2005');
// bmw-x5-e53-2005
mywap.az · 16.10.2026 00:48
<?php
function money(float|int $amount): string
{
return number_format($amount, 0, ',', ' ') . ' AZN';
}

echo money(25200);
// 25 200 AZN

Cavab yaz

Yazmaq üçün sayt ID-nizlə daxil olun. Daxil ol

İlk sehife
© 2026 MyWap.az
Azəri saytlar