Asked  7 Months ago    Answers:  4   Viewed   28 times

If I have a function:

function this($a){
   return $a;
}

If I wanted to redefine the function, would it be as simple as rewriting it?

function this($a, $b){  //New this function
   return $a * $b;
}

 Answers

87

Nope, that throws an error:

Fatal error: Cannot redeclare foo()

The runkit provides options, including runkit_function_rename() and runkit_function_redefine().

Wednesday, March 31, 2021
 
WooDzu
answered 7 Months ago
15
function round_up($value, $precision=0) {
    $power = pow(10,$precision);
    return ceil($value*$power)/$power;
}
function round_down($value, $precision=0) {
    $power = pow(10,$precision);
    return floor($value*$power)/$power;
}
Saturday, May 29, 2021
 
RenegadeAndy
answered 5 Months ago
51

While @Luceos answer is technically correct (the best kind of correct), it does not answer the question you asked, namely is doing this better, or do includes happen regardless of function calls?

I tested this in the most basic way (OP, why didn't you?):

<?php
echo "Testing...";

function doThing() {
    include nonExistantFile.php;
}
//doThing();
echo "Done testing.";

Results:

if I call doThing(); I get a file not found warning.

If I comment out doThing();... there is no error! So you can save file load time by doing this.

Thursday, August 5, 2021
 
Pwner
answered 3 Months ago
22

add these code into the top of your script

@set_magic_quotes_runtime(false);
ini_set('magic_quotes_runtime', 0);
Wednesday, August 18, 2021
 
Warrior
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :