I have a php code in which I am getting the error message Notice: Undefined variable: c at LineA
<?php echo HelloWorld($a, $b = 6, $c); ?> // LineA
The function definition is shown below:
function HelloWorld($a,$b = 0,$c = [],$max_text_length = 50) {
}
In order to fix the problem, I have added LineB above LineA.
<?php $c=[] ?> // LineB
<?php echo HelloWorld($a, $b = 6, $c); ?> // LineA
Problem Statement:
I am wondering if there any way I can fix the undefined variable problem for that paritcular case.
If you don't need to change the
$cvariable don't do it you have already set a default value in the function.Result: