PHP function won't execute when called -


I'm having trouble with this function. It is supposed to echo out some stuff, but for some reason when I I do not call it.

Here is the function:

  $ count = count ($ info ['level']); Function displayInfo () {for ($ i = 0; $ i & lt; $ count; $ i ++) {echo "[b]" $ Info ['name'] [$ i]. "[/ B] \ n \ n" $ info ['level'] [$ i]. "\ N Value:" $ info ['price'] [$ i]. \ N Sealback: ". Info ['sell'] [$ I]." \ N Location: ". $ Location". Type \ N \ n: $. Info ['type'] [$ i]. \ "Element:" $ Info ['element'] [$ i]. \ NDamage: "$ info ['damage' ] [$ I]. "\ NBTH:". $ Info ['bth]] [$ i]. "\ N \ nSpecial". "Hit \ N:" $ info [' hits'] [$ i]. "Type \ N:". $ Info ['stype'] [$ i]. \ NElement: ". Info $ [Sealement '] [$ i]." \ NDamage: "$ info ['sdamage'] [$ i]." \ NBTH: ". $ Info ['sbth'] [$ i]. \ \ \ \ \ \ \ \ $ Info ['rate'] [$ I] \ N \ n Description \ n ". $ Description "\ N". $ Img "\ N \ n \ n"; }}  

And here is the code that I use to call the function:

   

I do not know what is wrong - this is not a syntax error, there is no page load of an annotation.

Thanks in advance.

You can exclude $ count and $ info < / Code> Variables are declaring:

  // $ info already exists $ count = count ($ info ['level']); // and $ count is implemented here displayInfo () {for ($ i = 0; $ i & lt; $ count; $ i ++) ...  

In PHP, a A function is not visible within the declared outside variable function.


If you want your "external" variable to appear from within the function, then you have to declare them as a function:

$ count = Count ($ info ['level']); Function displayInfo () {global $ count, $ info; // $ count is now visible; ($ I = 0; $ i & lt; $ count; $ i ++) for $ info for the same ...


But this variable is usually To pass the parameter is considered as better function: You have to declare them as parameters:

  function displayInfo ($ count, $ info) {for ($ i = 0 ; $ I & lt; $ count; $ i ++) ...  

And pass it on to the function while calling it:

  $ Count = count (...); DisplayInfo ($ count, $ information);  

Passing the parameter instead of using the global variable ensures that you know what your work is using - and modify it.


Edit: Thanks for the note, X-Istence! The code given was not enough to read: - (


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -