# php -v (default PHP version) # From PHP 8.0 to PHP 7.4: sudo a2dismod php8.0 sudo a2enmod php7.4 sudo update-alternatives –set php /usr/bin/php7.4 sudo service apache2 restart # From PHP 7.4 to PHP 8.0: sudo a2dismod php7.4 sudo a2enmod php8.0 sudo update-alternatives –set php /usr/bin/php8.0 sudo service apache2 restart

Sorting array value without using built in php like sort() etc Bubble sort in php <?php $array =array(‘2′,’4′,’8′,’5′,’1′,’7′,’6′,’9′,’10’,’3′); echo ‘Unsorted array’; print_r($array); for($i = 0; $i<count($array); $i++){ for($j = 0; $j <count($array)-1; $j++){ if($array[$j] > $array[$j+1]){ $temp = $array[$j+1]; $array[$j+1] = $array[$j]; $array[$j] = $temp; } } } echo ‘Sorted array’; print_r($array); ?> Reverse Order Sorting <?php $array = array(‘2′,’4′,’8′,’5′,’1′,’7′,’6′,’9′,’10’,’3′); echo ‘Unsorted array’; print_r($array); for($i = 0; $i<count($array); $i++){ for($j = 0; $j <count($array)-1; $j++){…

Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted To get the current memory_limit value, run: php -r “echo ini_get(‘memory_limit’).PHP_EOL;” Check php configuration file php –ini sudo nano /usr/local/etc/php/7.4/php.ini Try increasing the limit in your php.ini file (ex. /etc/php5/cli/php.ini for Debian-like systems): ; Use -1 for unlimited or define an explicit value like 2G memory_limit = -1

Step 1: Create Database Table CREATE TABLE `info` ( `id` int(11) NOT NULL, `name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Step 2: Create index.php File <html> <head> <title>jQuery Add & Remove Dynamically Input Fields in PHP</title> </head> <body> <h1>jQuery Add & Remove Dynamically Input Fields in PHP</h1> <form name=”add_me” id=”add_me”> <table id=”dynamic”> <input type=”text” name=”name[]” placeholder=”Enter Your Name” /> <button type=”button” name=”add” id=”add_input”>Add</button> </table> <input type=”button” name=”submit” id=”submit” value=”Submit” /> </form> <script src=””></script> <script>…

<?php $html = file_get_contents(‘’); //get the html returned from the following url $pokemon_doc = new DOMDocument(); libxml_use_internal_errors(TRUE); //disable libxml errors if(!empty($html)){ //if any html is actually returned $pokemon_doc->loadHTML($html); libxml_clear_errors(); //remove errors for yucky html $pokemon_xpath = new DOMXPath($pokemon_doc); //get all the h2’s with an id $pokemon_row = $pokemon_xpath->query(‘//h2[@class]’); if($pokemon_row->length > 0){ foreach($pokemon_row as $row){ echo $row->nodeValue . “<br/>”; } } } ?> Read More:

<?php header(‘Content-type: application/excel’); $filename = ‘filename.xls’; header(‘Content-Disposition: attachment; filename=’.$filename); $data = ‘<html xmlns:x=”urn:schemas-microsoft-com:office:excel”> <head> <title>Page Title</title> </head> <body> <table><tr><td>Cell 1</td><td>Cell 2</td></tr></table> </body></html>’; echo $data; ?> <?php //index.php $error = ”; $name = ”; $email = ”; $subject = ”; $mobile = ”; $message = ”; function clean_text($string) { $string = trim($string); $string = stripslashes($string); $string = htmlspecialchars($string); return $string; } if(isset($_POST[”submit”])) { if(empty($_POST[”name”])) { $error .= ‘<p><label class=”text-danger”>Please Enter your Name</label></p>’; } else { $name = clean_text($_POST[”name”]); if(!preg_match(“/^[a-zA-Z ]*$/”,$name)) { $error .= ‘<p><label class=”text-danger”>Only letters and white space allowed</label></p>’; } } if(empty($_POST[”email”])) { $error .= ‘<p><label class=”text-danger”>Please Enter your… Create index.php file and put code inside of index.php file In this tutorial, we will learn how to data store inside of CSV file using PHP. CSV is a comma-separated value file in which it stores tabular data in plain text format. It stores one record in one line and for the second record, it will store in the second line. <?php //index.php $error = ”; $name = ”; $email = ”; $subject =…

Faster PHP Cloud Hosting