Dump all PHP variables
$all_vars = get_defined_vars();
print_r($all_vars);
Create an array for a range (e.g: array with number from 1 to 9)
$number = 9;
for ($i = 1; $i <= $number; ++$i) {
Dump all PHP variables
$all_vars = get_defined_vars();
print_r($all_vars);
Create an array for a range (e.g: array with number from 1 to 9)
$number = 9;
for ($i = 1; $i <= $number; ++$i) {
| Assuming I have three different PHP versions on my system: | |
| 1. PHP 5.6 | |
| 2. PHP 7.1 | |
| 3. PHP 7.2 | |
| To switch two between versions, add these aliases into your ~/.bashrc file: | |
| alias php5671='sudo a2dismod php5.6 ; sudo a2enmod php7.1 ; sudo service apache2 restart ; echo 2 | sudo update-alternatives --config php' | |
| alias php5672='sudo a2dismod php5.6 ; sudo a2enmod php7.2 ; sudo service apache2 restart ; echo 3 | sudo update-alternatives --config php' |
| Backup with bunzip | |
| tar cvfj file.tar.bz2 * | |
| tar cvfj file.tar.bz2 /path/to/directory_to_backup/ | |
| Extract from bunzip to directory 'archive' | |
| tar -xvf archive.tar.bz2 ./ | |
| Compress file to XZ file (Lossless Data Compression Tool) deleting the original file | |
| xz file.sql |
| ; For dev only | |
| expose_php=Off | |
| log_errors=On | |
| error_log=/var/log/httpd/php_scripts_error.log | |
| file_uploads=On | |
| ;open_basedir="/var/www/html/" | |
| error_reporting = E_ALL | |
| ; Should be 'off' on prod server | |
| allow_url_fopen=On |
| Get how many rows in whole database | |
| SELECT SUM(TABLE_ROWS) | |
| FROM INFORMATION_SCHEMA.TABLES | |
| WHERE TABLE_SCHEMA = 'db_name'; | |
| $ sudo dpkg --add-architecture i386 | |
| $ sudo apt update | |
| $ wget -qO- https://dl.winehq.org/wine-builds/Release.key | sudo apt-key add - | |
| $ sudo apt-add-repository 'deb http://dl.winehq.org/wine-builds/ubuntu/ bionic main' | |
| $ sudo apt update |
| <?php | |
| $array = [1,2,3,4,5,6,7]; | |
| $count_array = count($array); | |
| $placeholders = implode(',', array_fill(0, $count_array, '?')); | |
| $query = $DB->Prepare(' | |
| SELECT id, name | |
| FROM table_name | |
| WHERE id IN (' . $placeholders . ') | |
| '); |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>The Center </title> | |
| <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet"> | |
| <style> | |
| html, body { | |
| height: 100%; | |
| } |
List of table's names only
SELECT `COLUMN_NAME`
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_SCHEMA`='db name'
AND `TABLE_NAME`='table name';
Select all rows with the same value
SELECT e1.*
This is a way to install and set up Nginx, MariaDB and PHP-FPM on Ubuntu 20.04.
NOTE: This has been prepared for ease of use in mind, not security, mostly in development machine. Please do not use these instructions to setup on a public server environment. Use other proper manuals instead.
First fetch the latest package list of Ubuntu:
$ sudo apt update