Uncaught Error: Undefined constant “PHPMailer\PHPMailer\FILTER_FLAG_SCHEME_REQUIRED”

The FILTER_FLAG_HOST_REQUIRED filter flag was deprecated in PHP 7.3 and there are no longer any references to it in the PHPMailer code base. So a straightforward fix should be to simply update PHPMailer. If you were using composer this would be automatic and very simple, but you’re not, so you’ll have to download the latest version and install it yourself as per the readme.

Fatal error: Uncaught Error: Undefined constant PHPMailer\PHPMailer\FILTER_FLAG_HOST_REQUIRED" in C:\xampp\htdocs\phpmailer\PHPMailer.php:3598 Stack trace: #0 C:\xampp\htdocs\phpmailer\PHPMailer.php(3564): PHPMailer\PHPMailer\PHPMailer::isValidHost('localhost') #1 C:\xampp\htdocs\phpmailer\PHPMailer.php(2304): PHPMailer\PHPMailer\PHPMailer->serverHostname() #2 C:\xampp\htdocs\phpmailer\PHPMailer.php(1421): PHPMailer\PHPMailer\PHPMailer->createHeader() #3 C:\xampp\htdocs\phpmailer\PHPMailer.php(1316): PHPMailer\PHPMailer\PHPMailer->preSend() #4 C:\xampp\htdocs\scripts\form.php(43): PHPMailer\PHPMailer\PHPMailer->send() #5 C:\xampp\htdocs\contact.php(3): include('C:\xampp\htdocs...') #6 {main} thrown in C:\xampp\htdocs\phpmailer\PHPMailer.php on line 3598

javascript code for make slugs

replace all non-alphanumerical characters with dashes

<script>
  $("#inputSlug").keyup(function() {
  var Text = $(this).val();
  Text = Text.toLowerCase();
  Text = Text.replace(/[^a-zA-Z0-9]+/g,'-');
  $("#inputSlug").val(Text);        
});
</script>

meta description wordpress without plugin

Add the following code to the functions.php file.

function aditya_meta_description() {
    global $post;
    if ( is_singular() ) {
        $des_post = strip_tags( $post->post_content );
        $des_post = strip_shortcodes( $des_post );
        $des_post = str_replace( array("\n", "\r", "\t"), ' ', $des_post );
        $des_post = trim(mb_substr( $des_post, 0, 300, 'utf8' ));
      echo '<meta name="description" content="' . ($des_post) . '">'. "\n";
		 echo '<meta name="keywords" content="' . ($des_post) . '">'. "\n";
    }
    if ( is_home() ) {
      echo '<meta name="description" content="' . get_bloginfo( "description" ) . '" />' . "\n";
		   echo '<meta name="keywords" content="' . get_bloginfo( "description" ) . '" />' . "\n";
    }
    if ( is_category() ) {
        $des_cat = strip_tags(category_description());
      echo '<meta name="description" content="' . $des_cat . '" />' . "\n";
		  echo '<meta name="keywords" content="' . $des_cat . '" />' . "\n";
    }
}
add_action( 'wp_head', 'aditya_meta_description');

get file created date php

To get the file creation date in PHP, you can use the filectime() function. This function returns the creation time of the file, as a Unix timestamp. This code will output the creation date of the file in the format “Y-m-d H:i:s”, e.g. “2022-01-01 12:00:00”.

<?php

$zipfile = '/home/xxxx/public_html/public/public.zip';
if (file_exists($zipfile)) { 
  $file_name = pathinfo($zipfile);
  $dirName=$file_name['dirname'];
  $fileFullName=$file_name['basename'];
  $fileExtenstion=$file_name['extension'];
  $fileName=$file_name['filename'];
  $size = filesize($zipfile);
  $units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
  $power = $size > 0 ? floor(log($size, 1024)) : 0;   
  //echo $dirName."<br>".$fileFullName."<br>".$fileExtenstion."<br>".$fileName."<br>".date ("F d Y H:i:s.", filemtime($zipfile));
  echo $fileFullName."<br>".date ("F d Y H:i:s.", filemtime($zipfile))."<br>".number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];;
}

?>

Get file size in gb

gd extension php ubuntu

will usually find the correct package and version for your install setup and just install everything

sudo apt-get update
sudo apt-get install php-gd
sudo service apache2 restart

For 5.6 PHP

sudo apt-get install php5.6-gd

For 7.0 PHP

sudo apt-get install php7.0-gd

For 8.0 PHP

sudo apt-get install php8.0-gd

Creation of dynamic property CI_Router::$uri is deprecated Filename: core/Router.php

error in CodeIgniter website after update php 7.4 to php 8.2

how to resolve error CodeIgniter website error PHP Warning Deprecated: Creation of dynamic property is deprecated

Adding this just above the class{ will fix it:

#[\AllowDynamicProperties]

/system/core/URI.php

#[\AllowDynamicProperties]

class CI_URI {

/system/core/Router.php

#[\AllowDynamicProperties]

class CI_Router {

/system/core/Loader.php

#[\AllowDynamicProperties]

class CI_Loader {

/system/core/Controller.php

#[\AllowDynamicProperties]

class CI_Controller {   

/system/database/DB_driver.php

#[\AllowDynamicProperties]

abstract class CI_DB_driver {

Email : adityaypi@yahoo.com, Mobile : +91-9555699081

Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in

Migration to PHP 8.1 – how to fix Deprecated Passing null to parameter error – rename build in functions

$time2 = strtotime($task[$i]['out_date_time'] ?? '');
substr($task[$i]['out_user_agent'] ?? '',0,1)

Firstly, two things to bear in mind:

  1. PHP 8.1 deprecates these calls, it does not make them errors. The purpose of deprecation is to give authors advance notice to fix their code, so you and the authors of libraries you use have until PHP 9.0 comes out to fix things. So, don’t panic that not everything is fixed right away, and be patient with library maintainers, who will get to this in their own time.
  2. The quick fix in most cases is to use the null coalescing operator to provide a default value as appropriate, so you don’t need a long null check around every use. For instance, htmlspecialchars($something) can be replaced with htmlspecialchars($something ?? '')

Next, some options:

  • Depending how many cases you have, you may be able to just fix them manually a few at a time, either adding ?? '' or fixing a logic bug where you weren’t expecting a null anyway.
  • Create custom functions like nullable_htmlspecialchars and do a straight-forward find and replace in your code.
  • Create custom namespaced functions like nullableoverride\htmlspecialchars; then in any file where you add use function nullableoverride\htmlspecialchars; that function will be used instead of the built-in one. This has to be added in each file, though, so you may need a tool to automate adding it.
  • Use Rector to automate adding ?? '' to appropriate function calls, so you don’t have to edit them all by hand. Unfortunately, there doesn’t seem to be a built-in rule for this (yet), so you’d have to learn to write your own.
  • Possibly simpler, depending on your skills, use a regular expression find-and-replace to add the ?? '' to simple cases.

full php 8.2 install ubuntu

$sudo apt install php8.2 php8.2-cli php8.2-{curl,bz2,mbstring,intl}
$sudo apt install php8.2-{bcmath,fpm,xml,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,opcache,soap,cgi}
$sudo apt install php8.2-fpm
$sudo a2enconf php8.2-fpm
$sudo a2disconf php8.1-fpm #When upgrading from an older PHP version
$sudo service apache2 restart

Install PHP 8.2 modules on Ubuntu

sudo apt install php8.2-{bcmath,fpm,xml,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,opcache,soap,cgi}

get days between two dates in php

<?php
$datetime1 = date_create($subscription[$index]['end_date']);
$datetime2 = date_create(date('Y-m-d'));
$interval = date_diff($datetime1, $datetime2);
$NoOfDays= $interval->format('%a');
echo $NoOfDays;
?>

get country code from phone number php from string format

<?php
 $user_phone = "+919555699081";
 $len = strlen($user_phone);
 $phone = substr($user_phone, -10);
 $country_code = substr($user_phone, 0,$len -  strlen($phone));
 echo $country_code."-".$phone."-"; echo $user_phone; 
?>