php - Function returns lots of notices -
First of all, my skill level is the best, a hobbit - I'm new at all, if not all of you.
I am trying to create a function that is a I am trying to create this function: a) How to create a function b) I C) I hate to type, this is the idea of the function that came with interest to me. So, ideally, in my code, if type This is not working because I hope that when I type Here is the function I have created: to ensure that This function does not give any value to the function, a default value is set. I made some improvements to your function. & lt; Br / & gt; will return if no parameter / value is returned, many
& lt; Br / & gt; tag is equal to
$ num
& lt; Br / & gt;
getBrT () , this is a single
& gt; return the tag, but if type
getBrT (5) this five
& lt; Br / & gt; return the tag.
getBrT () . Do I always have a price to flatten? Am I trying to not be possible within PHP's obligations?
function getBrT2 ($ num) {// If the number is equal to 'nothing', 1 break - repeatedly Easy to call / Type the code ($ num = '') {echo '& lt; Br / '; } Else {// If the number is equal to 'some', breaks equal value $ i = 0; // Initial Counter ($ i & lt; $ num) {echo '& lt; Br / & gt; '; // sal = i ++;}}}
function getBrT2 ($ num = 1) {// default value 1 $ num = (int) $ num; // if the number is negative ($ num & lt; 1) {// if the number is negative 0 or negative then it would be numerically numerator of 1 $ num = 1; } Return str_repeat ('& lt; br / & gt;', $ num); // many & lt; Br / & gt; As requested, echo getBrT2 (1); // prints "
" Echo getBrT2 (5); // print out "
" Echo getBrT2 (''); // prints "
" Echo getBrT2 ('hello'); // prints "
"
0 .
is $ num is
0 or if a negative number, then we make it
1 .
str_repeat () as many
& lt; Br / & gt; tags
Comments
Post a Comment