Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 18 days ago.
Improve this question
I need replace create_function() for something else
add_action( 'plugins_loaded', create_function( '', 'global $Gestor_Cadastros; $Gestor_Cadastros = new Gestor_Cadastros();' ) );
I don't know about this, what can I do?
The create_function() function is considered obsolete as of PHP 7.2 and should be avoided for security reasons. It is recommended to use an anonymous closure instead:
add_action( 'plugins_loaded', function() {
global $Gestor_Registers;
$Gestor_Registers = new Gestor_Registers();
});
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
I have the following code on my php website from a theme i made a long time ago but it gives warnings on 7.4 and errors on 8.0
add_action('widgets_init', create_function('', 'return register_widget("Banners125");'));
Any suggestion on how i can fix this code in my wordpress theme for php 8.0?
I would like it to work on php 8.0
The function create_function was deprecated in 7.2 and removed in 8.0. Your code can be rewritten in several ways, one of which is:
add_action(
'widgets_init',
function() {
return register_widget("Banners125");
}
);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to change weekendDays to only include Sunday in my Carbon Instance. How can I do that?
Run:
Carbon::setWeekendDays([Carbon::SUNDAY]);
In your App\Providers\AppServiceProvider in the boot function.
Edit:
setWeekendDays is deprecated. Use macro instead.
Carbon::macro('isDayOff', function ($date) {
return $date->isSunday();
});
$isDayOff = $carbon_inst->isDayOff(): bool;
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Way 1:
public $foo = 1;
function(){
return $this->foo+1;
}
Way 2:
// with $foo = 1 in other function
function($foo){
return $foo+1;
}
Sorry for a 'dumb' question, someone can tell me what is the better way?
Second way is better and it is more canonical than first one. For more information please read this doc http://php.net/manual/en/functions.arguments.php
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a project with lots global variables.
Examples used in functions
function ChangePassForm( $VARS ) {
global $tpl, $iBtns, $db;
...
$db->query("....");
}
I can pretty easy guess what the question is:
"Why is it not working"?
ANSWER from PHP.net:
Anyway I voted to close the question.
#Piotr please refine the question or it will be closed.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to avoid creating another file just to escape the namespace.
Found the solution. For others interested see below.
namespace { function myFunction() { ... } }