remove multiple line in php from string

$contents = preg_replace("/[\r\n]+/", "\n", $contents); The + quantifier tells the pattern matcher to repeat the previous item once or more. So it'll grab all of the extras in a row and replace them with one.

Unknown: Automatic conversion of false to array is deprecated in /home/ubuntu/public_html/shop/catalog/controller/startup/startup.php on line 95

Error in opencart after upgrade php 8.2

Add this line :

if(!is_array($this->session->data)){ $this->session->data = []; }

Before

if (!isset($this->session->data['language']) || $this->session->data['language'] != $code) {	
			$this->session->data['language'] = $code;
		}

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

php all version release and end date

Hypertext Preprocessor (or simply PHP) is a general-purpose programming language originally designed for web development.

Each release branch of PHP is fully supported for two years from its initial stable release. During this period, bugs and security issues that have been reported are fixed and are released in regular point releases.

After this two-year period of active support, each branch is then supported for an additional year for critical security issues only. Releases during this period are made on an as-needed basis: there may be multiple point releases, or none, depending on the number of reports.

ReleaseReleasedActive SupportSecurity SupportLatest
8.26 months ago(08 Dec 2022)Ends in 1 year and 6 months(08 Dec 2024)Ends in 2 years and 6 months(08 Dec 2025)8.2.7(08 Jun 2023)
8.11 year and 6 months ago(25 Nov 2021)Ends in 5 months and 2 weeks(25 Nov 2023)Ends in 1 year and 5 months(25 Nov 2024)8.1.20(08 Jun 2023)
8.02 years and 6 months ago(26 Nov 2020)Ended 6 months ago(26 Nov 2022)Ends in 5 months and 2 weeks(26 Nov 2023)8.0.29(08 Jun 2023)
7.43 years and 6 months ago(28 Nov 2019)Ended 1 year and 6 months ago(28 Nov 2021)Ended 6 months ago(28 Nov 2022)7.4.33(03 Nov 2022)
7.34 years and 6 months ago(06 Dec 2018)Ended 2 years and 6 months ago(06 Dec 2020)Ended 1 year and 6 months ago(06 Dec 2021)7.3.33(18 Nov 2021)
7.25 years ago(30 Nov 2017)Ended 3 years and 6 months ago(30 Nov 2019)Ended 2 years and 6 months ago(30 Nov 2020)7.2.34(01 Oct 2020)
7.16 years ago(01 Dec 2016)Ended 4 years and 6 months ago(01 Dec 2018)Ended 3 years and 6 months ago(01 Dec 2019)7.1.33(24 Oct 2019)
7.07 years ago(03 Dec 2015)Ended 5 years ago(04 Jan 2018)Ended 4 years ago(10 Jan 2019)7.0.33(10 Jan 2019)
5.68 years ago(28 Aug 2014)Ended 6 years ago(19 Jan 2017)Ended 4 years ago(31 Dec 2018)5.6.40(10 Jan 2019)
5.59 years ago(20 Jun 2013)Ended 7 years and 11 months ago(10 Jul 2015)Ended 6 years and 10 months ago(21 Jul 2016)5.5.38(21 Jul 2016)
5.411 years ago(01 Mar 2012)Ended 8 years ago(14 Sep 2014)Ended 7 years ago(14 Sep 2015)5.4.45(03 Sep 2015)
5.313 years ago(30 Jun 2009)Ended 11 years ago(30 Jun 2011)Ended 8 years ago(14 Aug 2014)5.3.29(14 Aug 2014)
5.216 years ago(02 Nov 2006)Ended 14 years ago(02 Nov 2008)Ended 12 years ago(06 Jan 2011)5.2.17(06 Jan 2011)
5.117 years ago(24 Nov 2005)Ended 16 years ago(24 Aug 2006)Ended 16 years ago(24 Aug 2006)5.1.6(24 Aug 2006)
5.018 years ago(13 Jul 2004)Ended 17 years ago(05 Sep 2005)Ended 17 years ago(05 Sep 2005)5.0.5(05 Sep 200
You can check the version that you are currently using by running:
php --version

how to remove img tag, if image is not displayed or available for webpage

अगर छवि प्रदर्शित नहीं है या वेबपेज के लिए उपलब्ध नहीं है तो img टैग को कैसे हटाएं

Current Code

<img src="<?php echo $metaData->image; ?>" class="card-img-top" alt="..." >

Modified Code

To remove img tag for image error add this code – onerror=”$(this).remove()”

<img src="<?php echo $metaData->image; ?>" class="card-img-top" alt="..." onerror="$(this).remove()" >

error in opencart ecommerce website after updating php 7.4 to php 8.2

Unknown: Creation of dynamic property Request::$request is deprecated in /home/ubuntu/public_html/shop/system/library/request.php on line 27Unknown: Creation of dynamic property Session\DB::$db is deprecated in /home/ubuntu/public_html/shop/system/library/session/db.php on line 15Unknown: Creation of dynamic property Proxy::$getTranslations is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$__construct is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$__get is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$__set is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: mysqli::real_escape_string(): Passing null to parameter #1 ($string) of type string is deprecated in /home/ubuntu/public_html/shop/system/library/db/mysqli.php on line 45Unknown: Creation of dynamic property Openbay::$logger is deprecated in /home/ubuntu/public_html/shop/system/library/openbay.php on line 22Unknown: Creation of dynamic property Proxy::$getLanguage is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$getLanguages is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$__construct is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$__get is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$__set is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Cart\Customer::$config is deprecated in /home/ubuntu/public_html/shop/system/library/cart/customer.php on line 14Unknown: Creation of dynamic property Cart\Customer::$db is deprecated in /home/ubuntu/public_html/shop/system/library/cart/customer.php on line 15Unknown: Creation of dynamic property Cart\Customer::$request is deprecated in /home/ubuntu/public_html/shop/system/library/cart/customer.php on line 16Unknown: Creation of dynamic property Cart\Customer::$session is deprecated in /home/ubuntu/public_html/shop/system/library/cart/customer.php on line 17Unknown: Creation of dynamic property Proxy::$getCurrencyByCode is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$getCurrencies is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$__construct is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$__get is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Proxy::$__set is deprecated in /home/ubuntu/public_html/shop/system/engine/proxy.php on line 30Unknown: Creation of dynamic property Cart\Currency::$db is deprecated in /home/ubuntu/public_html/shop/system/library/cart/currency.php on line 7Unknown: Creation of dynamic property Cart\Currency::$language is deprecated in /home/ubuntu/public_html/shop/system/library/cart/currency.php on line 8Unknown: Creation of dynamic property Cart\Tax::$config is deprecated in /home/ubuntu/public_html/shop/system/library/cart/tax.php on line 7Unknown: Creation of dynamic property Cart\Tax::$db is deprecated in /home/ubuntu/public_html/shop/system/library/cart/tax.php on line 8Unknown: Creation of dynamic property Cart\Weight::$db is deprecated in /home/ubuntu/public_html/shop/system/library/cart/weight.php on line 7Unknown: Creation of dynamic property Cart\Weight::$config is deprecated in /home/ubuntu/public_html/shop/system/library/cart/weight.php on line 8Unknown: Creation of dynamic property Cart\Length::$db is deprecated in /home/ubuntu/public_html/shop/system/library/cart/length.php on line 7Unknown: Creation of dynamic property Cart\Length::$config is deprecated in /home/ubuntu/public_html/shop/system/library/cart/length.php on line 8Unknown: Creation of dynamic property Cart\Cart::$config is deprecated in /home/ubuntu/public_html/shop/system/library/cart/cart.php on line 7Unknown: Creation of dynamic property Cart\Cart::$customer is deprecated in /home/ubuntu/public_html/shop/system/library/cart/cart.php on line 8Unknown: Creation of dynamic property Cart\Cart::$session is deprecated in /home/ubuntu/public_html/shop/system/library/cart/cart.php on line 9Unknown: Creation of dynamic property Cart\Cart::$db is deprecated in /home/ubuntu/public_html/shop/system/library/cart/cart.php on line 10Unknown: Creation of dynamic property Cart\Cart::$tax is deprecated in /home/ubuntu/public_html/shop/system/library/cart/cart.php on line 11Unknown: Creation of dynamic property Cart\Cart::$weight is deprecated in /home/ubuntu/public_html/shop/system/library/cart/cart.php on line 12Unknown: Creation of dynamic property Openbay::$logger is deprecated in /home/ubuntu/public_html/shop/system/library/openbay.php on line 22

Unknown: Creation of dynamic property Request::$request is deprecated in /home/ubuntu/public_html/shopping/system/library/request.php on line 26

Old Reques.php file

<?php
/**
 * @package		OpenCart
 * @author		Daniel Kerr
 * @copyright	Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
 * @license		https://opensource.org/licenses/GPL-3.0
 * @link		https://www.opencart.com
*/

/**
* Request class
*/
class Request {
	public $get = array();
	public $post = array();
	public $cookie = array();
	public $files = array();
	public $server = array();
	
	/**
	 * Constructor
 	*/
	public function __construct() {
		$this->get = $this->clean($_GET);
		$this->post = $this->clean($_POST);
		$this->request = $this->clean($_REQUEST);
		$this->cookie = $this->clean($_COOKIE);
		$this->files = $this->clean($_FILES);
		$this->server = $this->clean($_SERVER);
	}
	
	/**
     * 
	 * @param	array	$data
	 *
     * @return	array
     */
	public function clean($data) {
		if (is_array($data)) {
			foreach ($data as $key => $value) {
				unset($data[$key]);

				$data[$this->clean($key)] = $this->clean($value);
			}
		} else {
			$data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
		}

		return $data;
	}
}

New request.php file

<?php
/**
 * @package		OpenCart
 * @author		Daniel Kerr
 * @copyright	Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
 * @license		https://opensource.org/licenses/GPL-3.0
 * @link		https://www.opencart.com
*/

/**
* Request class
*/
class Request {
	public $get = array();
	public $post = array();
	public $cookie = array();
	public $request = array();
	public $files = array();
	public $server = array();
	
	/**
	 * Constructor
 	*/
	public function __construct() {
		$this->get = $this->clean($_GET);
		$this->post = $this->clean($_POST);
		$this->request = $this->clean($_REQUEST);
		$this->cookie = $this->clean($_COOKIE);
		$this->files = $this->clean($_FILES);
		$this->server = $this->clean($_SERVER);
	}
	
	/**
     * 
	 * @param	array	$data
	 *
     * @return	array
     */
	public function clean($data) {
		if (is_array($data)) {
			foreach ($data as $key => $value) {
				unset($data[$key]);

				$data[$this->clean($key)] = $this->clean($value);
			}
		} else {
			$data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
		}

		return $data;
	}
}

get last inserted row in Laravel eloquent

get last inserted row in Laravel eloquent with where and condition

<?php

$data = array();
  $lang = $request->lang;
  $reference_id = $request->reference_id;
  $call_state = $request->call_state;
  try{
    $data['incall'] = CalIncallWebhook::on($lang)->where(['call_state'=> $call_state,'reference_id'=> $reference_id])->latest()->first();
  }
  catch(Exception $ex)
  {
  
  }
 
 return $this->sendResponse($data, 'Successfully');   

?>

how can i get raw data in laravel-php api from webhook and store into file

How to write code for InCall and AfterCall webhook url for Myoperator

InCall Webhook Myoperator

public function inCallWebhook(Request $request)
{
  $data = array();
  $data['data'] = json_decode(Request::createFromGlobals()->getContent());
  $input = array();
  try{
  $input['incall_id'] = $data['data']->id;
  $input['uid'] = $data['data']->uid;
  $input['reference_id'] = $data['data']->reference_id;
  $input['company_id'] = $data['data']->company_id;
  $input['clid_raw'] = $data['data']->clid_raw;
  $input['clid'] = $data['data']->clid;
  $input['rdnis'] = $data['data']->rdnis;
  $input['call_state'] = $data['data']->call_state;
  $input['event'] = $data['data']->event;
  $input['status'] = $data['data']->status;
  $input['users'] = $data['data']->users;
  $input['created'] = $data['data']->created;
  $input['call_time'] = $data['data']->call_time;
  $calIncallWebhook = new CalIncallWebhook($input);
  $calIncallWebhook->save();
  }
  catch(Exception $ex)
  {
  $fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/public/incall.txt","w");
  //fwrite($fp, Request::createFromGlobals()->getContent());
  fwrite($fp, $ex->getMessage());
  fclose($fp);
  }
 
 return $this->sendResponse($data, 'Successfully');   
}

AfterCall Webhook Myoperator


public function afterCallWebhook(Request $request)
{
  $data = array();
  $data['data'] = json_decode(Request::createFromGlobals()->getContent());
  $input = array();
  try{
  $input['aftercall_id'] = $data['data']->_ai;
  $input['company_id'] = $data['data']->_ci;
  $input['caller_cr'] = $data['data']->_cr;
  $input['caller_cl'] = $data['data']->_cl;
  $input['calllocation_se'] = $data['data']->_se;
  $input['status_su'] = $data['data']->_su;
  $input['call_st'] = $data['data']->_st;
  $input['call_et'] = $data['data']->_et;
  $input['time_ss'] = $data['data']->_ss;
  $input['duration_dr'] = $data['data']->_dr;
  $input['calltype_ev'] = $data['data']->_ev;
  $input['reference_ri'] = $data['data']->_ri;
  $calAftercallWebhook = new CalAftercallWebhook($input);
  $calAftercallWebhook->save();
  }
  catch(Exception $ex)
  {
  $fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/public/aftercall.txt","w");
  //fwrite($fp, Request::createFromGlobals()->getContent());
  fwrite($fp, $ex->getMessage());
  fclose($fp);
  }
  return $this->sendResponse($data, 'Successfully');     
}
public function InCallWebhookCode(Request $request)
{
  $data = array();
  $data['data'] = json_decode(Request::createFromGlobals()->getContent());
  $fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/public/incall.txt","w");
  fwrite($fp, Request::createFromGlobals()->getContent());
  fclose($fp);  
  return $this->sendResponse($data, 'Successfully'); 

}
public function inCallWebhook(Request $request)
{
  $data = array();
  $aaaa['raw'] = json_decode(Request::createFromGlobals()->getContent());
  $data['data'] = json_decode($aaaa['raw']->message->data);
  $fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/public/incall.txt","w");
  fwrite($fp, Request::createFromGlobals()->getContent());
OR
  fwrite($fp,  $aaaa['raw']->message->data);
  fclose($fp);
  return $this->sendResponse($data, 'Successfully');   
}

PHP Filesystem Functions

PHP Filesystem Functions

FunctionDescription
basename()Returns the filename component of a path
chgrp()Changes the file group
chmod()Changes the file mode
chown()Changes the file owner
clearstatcache()Clears the file status cache
copy()Copies a file
delete()See unlink()
dirname()Returns the directory name component of a path
disk_free_space()Returns the free space of a filesystem or disk
disk_total_space()Returns the total size of a filesystem or disk
diskfreespace()Alias of disk_free_space()
fclose()Closes an open file
feof()Checks if the “end-of-file” (EOF) has been reached for an open file
fflush()Flushes buffered output to an open file
fgetc()Returns a single character from an open file
fgetcsv()Returns a line from an open CSV file
fgets()Returns a line from an open file
fgetss()Deprecated from PHP 7.3. Returns a line from an open file – stripped from HTML and PHP tags
file()Reads a file into an array
file_exists()Checks whether or not a file or directory exists
file_get_contents()Reads a file into a string
file_put_contents()Writes data to a file
fileatime()Returns the last access time of a file
filectime()Returns the last change time of a file
filegroup()Returns the group ID of a file
fileinode()Returns the inode number of a file
filemtime()Returns the last modification time of a file
fileowner()Returns the user ID (owner) of a file
fileperms()Returns the file’s permissions
filesize()Returns the file size
filetype()Returns the file type
flock()Locks or releases a file
fnmatch()Matches a filename or string against a specified pattern
fopen()Opens a file or URL
fpassthru()Reads from the current position in a file – until EOF, and writes the result to the output buffer
fputcsv()Formats a line as CSV and writes it to an open file
fputs()Alias of fwrite()
fread()Reads from an open file (binary-safe)
fscanf()Parses input from an open file according to a specified format
fseek()Seeks in an open file
fstat()Returns information about an open file
ftell()Returns the current position in an open file
ftruncate()Truncates an open file to a specified length
fwrite()Writes to an open file (binary-safe)
glob()Returns an array of filenames / directories matching a specified pattern
is_dir()Checks whether a file is a directory
is_executable()Checks whether a file is executable
is_file()Checks whether a file is a regular file
is_link()Checks whether a file is a link
is_readable()Checks whether a file is readable
is_uploaded_file()Checks whether a file was uploaded via HTTP POST
is_writable()Checks whether a file is writable
is_writeable()Alias of is_writable()
lchgrp()Changes the group ownership of a symbolic link
lchown()Changes the user ownership of a symbolic link
link()Creates a hard link
linkinfo()Returns information about a hard link
lstat()Returns information about a file or symbolic link
mkdir()Creates a directory
move_uploaded_file()Moves an uploaded file to a new location
parse_ini_file()Parses a configuration file
parse_ini_string()Parses a configuration string
pathinfo()Returns information about a file path
pclose()Closes a pipe opened by popen()
popen()Opens a pipe
readfile()Reads a file and writes it to the output buffer
readlink()Returns the target of a symbolic link
realpath()Returns the absolute pathname
realpath_cache_get()Returns realpath cache entries
realpath_cache_size()Returns realpath cache size
rename()Renames a file or directory
rewind()Rewinds a file pointer
rmdir()Removes an empty directory
set_file_buffer()Alias of stream_set_write_buffer(). Sets the buffer size for write operations on the given file
stat()Returns information about a file
symlink()Creates a symbolic link
tempnam()Creates a unique temporary file
tmpfile()Creates a unique temporary file
touch()Sets access and modification time of a file
umask()Changes file permissions for files
unlink()Deletes a file

implode in php

The implode() function returns a string from the elements of an array.

Note: The implode() function accept its parameters in either order. However, for consistency with explode(), you should use the documented order of arguments.

Note: The separator parameter of implode() is optional. However, it is recommended to always use two parameters for backwards compatibility.

Note: This function is binary-safe.

implode(separator,array)
<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);
?>