php 8.1 full install ubuntu

sudo apt update
sudo apt install --no-install-recommends php8.1
php -v

sudo apt install php8.1-fpm
sudo a2enconf php8.1-fpm
sudo apt-get install php8.1-PACKAGE_NAME
sudo apt-get install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath

This command will install the following modules:

  • php8.1-cli – command interpreter, useful for testing PHP scripts from a shell or performing general shell scripting tasks
  • php8.1-common – documentation, examples, and common modules for PHP
  • php8.1-mysql – for working with MySQL databases
  • php8.1-zip – for working with compressed files
  • php8.1-gd – for working with images
  • php8.1-mbstring – used to manage non-ASCII strings
  • php8.1-curl – lets you make HTTP requests in PHP
  • php8.1-xml – for working with XML data
  • php8.1-bcmath – used when working with precision floats
php -m
NOTICE: Not enabling PHP 8.1 FPM by default.
NOTICE: To enable PHP 8.1 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php8.1-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Processing triggers for libapache2-mod-php8.1 (8.1.9-1+ubuntu18.04.1+deb.sury.or                                                                                        g+1) ...

If wordpress website not working

sudo a2disconf php8.1-fpm
sudo a2dismod php7.4
sudo a2enmod php8.0
  
sudo service apache2 restart

when is php 7.4 end of life

PHP 7.4 goes end of life (EOL) on the 28 November 2022 meaning known security flaws will no longer be fixed and sites are exposed to significant security vulnerabilities. It is important to update them to a newer version.

PHP 7.4, the next PHP 7 minor release, has been released for General Availability as of November 28th, 2019.

create stdclass object in php

   $data = array();  
$object = new stdClass();
$object->business_id= '';
$object->phone_number_id= '';
$object->recipient_phone_number= '';
$object->user_access_token= '';
$object->waba_id= '';
$object->version= '';
$data[0] = $object;

Delete file in php

function delete_file($pFilename)
{
    if ( file_exists($pFilename) ) { 
        //  Added by muhammad.begawala@gmail.com
        //  '@' will stop displaying "Resource Unavailable" error because of file is open some where.
        //  'unlink($pFilename) !== true' will check if file is deleted successfully.
        //  Throwing exception so that we can handle error easily instead of displaying to users.
        if( @unlink($pFilename) !== true )
            throw new Exception('Could not delete file: ' . $pFilename . ' Please close all applications that are using it.');
    }   
    return true;
}
try {
    if( delete_file('file_name') === true ){
      echo 'File Deleted';
    }
       
}
catch (Exception $e) {
   echo $e->getMessage(); // will print Exception message defined above.
}
try {
    if( file_exists($f) === true  ){
      if( @unlink($f) !== true )
      throw new Exception('Could not delete file: ' . $f . ' Please close all applications that are using it.');
      //echo 'File Deleted';
    }
       
}
catch (Exception $e) {
   echo $e->getMessage(); // will print Exception message defined above.
}

unlink in php

<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);

unlink("test.txt");
?>

how to get and set value from and to from input text using jQuery when we have multiple input textbox in html

how to get and set value from and to from input text using jQuery when we have multiple input textbox in html

 $('#example tfoot input[type="text"]').last().val($(this).val())
# HTML
<input type="text" name="quantity" value="1" class="input-text ">
<input type="text" name="quality" value="2" class="input-text ">

#jquery
$('[name]').first().val() // 1
$('[name]').last().val() // 2

new OTP send or resend OTP after 60 seond in php laravel

if (User::where('phone', $input['phone'])->exists()) {
  $success['result']=User::where('phone', $input['phone'])->whereRaw("updated_at >=('" . date('Y-m-d H:i:s') . "'-INTERVAL 60 SECOND) AND updated_at <='" . date('Y-m-d H:i:s') . "'")->exists();
  if(!$success['result']){
    $success['otp']=$otp; 
  $affectedRows = User::where('phone', $input['phone'])->update(array('otp' => $otp,'password'=>Hash::make($otp)));
  }else { $isSend = 0; }
}else{
  $success['result']=false;
  $success['otp']=$otp;
  $input['password'] = Hash::make($otp);
  $input['otp']=$otp;
  $user = User::create($input);
}
if($isSend)
{
$otp_response=json_decode($this->sendOtp($data,$otp));
$success['otp_response']=$otp_response->status;
//$otp_response->status == "success"
}