Ad
  • Default User Avatar

    +1 is useless in your solutoin ,
    am I right or I am missing something here ?

  • Default User Avatar

    In PHP, all declared functions are global. So every time rgb is called, hex will be defined in the global scope. The second time you call rgb, it will try to define hex again in the global scope and will produce an error because hex is already defined. The same thing occurs on your other hosting site if you try to run more than one test at a time (just add one more print rgb(148, 0, 211); after your first one on the other site and you'll see).

  • Custom User Avatar

    Maybe it's a matter of PHP version? This (somewhat old) post suggests that support for local funcitons in PHP is... uhhh.... PHPy.
    Moving the local funciton to the global scope makes the solution work.