Call to undefined function password_hash() PHP 5.3.19 [duplicate] - php

This question already has answers here:
How do you use bcrypt for hashing passwords in PHP? [duplicate]
(11 answers)
Closed 8 years ago.
Hi I am try to use the password_hash() function like so
echo password_hash("mySecretPassword", PASSWORD_DEFAULT);
But I am gettig this error which I can figure out
Fatal error: Call to undefined function password_hash()
My current PHP version is 5.3.19 32 bit
What is the cause of this issue?

From the PHP docs.
password_hash()
(PHP 5 >= 5.5.0)
This means that only version after 5.5.0 has this method implemented. Running 5.3.0 will not work. There is however a fallback option posted in this answer.
You could also use the password_hash() compatibility pack.

Related

How can i Solve this error : Uncaught Error: Call to undefined function mysql_real_escape_string() [duplicate]

This question already has answers here:
mysql_real_escape_string is undefined
(5 answers)
How can I prevent SQL injection in PHP?
(27 answers)
Why shouldn't I use mysql_* functions in PHP?
(14 answers)
Closed 1 year ago.
I am using PHP 8.0 Version but recently i get this error :
Uncaught Error: Call to undefined function mysql_real_escape_string()
is there any solution for this ?
mysql_real_escape_string was DEPRECATED in PHP 5.5.0 and REMOVED in PHP 7.0.0.¹
PHP recommends using MySQLi or PDO instead.
¹ https://www.php.net/manual/en/function.mysql-real-escape-string.php

PHP Function create_function() is deprecated , the code cant work in newest PHP? [duplicate]

This question already has answers here:
PHP 7.2 Function create_function() is deprecated
(6 answers)
Closed 1 year ago.
I have a function which im not entirely sure how to convert it to get working in newest php
$eventSponsor = array_map(create_function('$o', 'return $o["id"];'), $event->sponsors);
which method should i use in newest php version ?
yeah i was searching and i found this method called anonymous function so the code be like
$awe function ($o) {
return $o["id"];
};
$eventSponsor = array_map($awe,$event->sponsors); ```

The each() function is deprecated. This message will be suppressed on further calls PHP 7.2 [duplicate]

This question already has answers here:
How can I update code that uses the deprecated each() function?
(12 answers)
Closed 4 years ago.
I have the below each() line in a PHP file on a server where I recently upgraded the PHP version from 5 to 7.
while(list($file, $info) = each($this->images))
The error below is thrown by the web server after the restart.
The each() function is deprecated. This message will be suppressed on further calls
What will be the correct way of re-writing the above line of code in PHP 7.2?
Thank you.
You should be able to swap out your each for a foreach in the most part.
<?php
foreach($this->images as $file => $info) {
// ...
}

Deprecated create_function() call [duplicate]

This question already has answers here:
PHP 7.2 Function create_function() is deprecated
(6 answers)
Closed 3 years ago.
I just updated my server to the latest version of php 7.2 and now I have some depreciation warnings. What should I do?
This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.
Here is my code:
if(!array_key_exists('callable', $this->translation_plural)) {
$this->translation_plural['callable'] = create_function('$n', $this->translation_plural['function']);
}
The documentation recommends using anonymous functions. Given that $this->translation_plural['function'] looks like it is a string, you should consider a rewrite.
If you want to get rid of the warning, you can use the following:
$this->translation_plural['callable'] = function($n) { return eval($this->translation_plural['function']); };
This doesn't help your code at all, you are still using eval() which is bad practise. The documentation warns against using it.
The only difference is, create_function() used it internally, now it is very explicit.

Fatal error: Uncaught Error: Call to undefined function ereg_replace() PHP 7 [duplicate]

This question already has answers here:
How can I convert ereg expressions to preg in PHP?
(4 answers)
Closed 3 years ago.
below code is giving me the fatal error in php 7
$jquery_click_hook = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name']));
is there any way to make it compatible with php 7?
Switch to preg_replaceDocs and update the expression to use preg syntax (PCRE) instead of ereg syntax (POSIX) where there are differencesDocs (just as it says to do in the manual for ereg_replaceDocs).
Your above code should be this way:
$jquery_click_hook = preg_replace("[^A-Za-z0-9]", "", strtolower($value['name']));
ereg_replace function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0. So you must have to use preg_replace() function instead of ereg_replace()

Categories