A-moment-with-php
A Moment With PHP⌗
Installation⌗
Let’s install with,
sudo pamcan -S php
Then a bit of config like described in Archlinux,
sudo nano /etc/php/php.ini
Changes are,
date.timezone = Asia/Dhaka
extension=mysqli
extension=pdo_mysql
Running⌗
To run a php file, we can use,
php file.php
To serve a php server, we can use,
php -S localhost:8000
Get the full article with,
DB⌗
For MySQL, we can use PDO
like,
<?php
$servername = "127.0.0.1";
$username = "root";
$password = "tree";
try {
$conn = new PDO("mysql:host=$servername;dbname=university", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>