I miss the hint, that with the help of namespaces, you can have multiple classes with the same name, but in different namespaces and are able to reference them accordingly with the help of use statements and aliases, even on the same file:
namespace App;
use App\Domain\Foo;
use App\Utils\Foo as UtilsFoo;
class Bar {
public function foobar() {
$foo = new Foo();
$utilFoo = new UtilsFoo();
$foo->doStuff();
$utilFoo->doStuff();
}
}
I'm not sure why I keep having error issues with some challenges. Its random. I tried 2 computers, 2 different browsers and I get this error for exercise 5 on this php namespace tutorial. Class Pizza and eat.php are locked and can't be edited. I've come across an error below like this before on another challenge.
Error! This PHP error is coming from your code. Read it carefully to debug! ( ! ) Fatal error: Uncaught Error: Class 'Pizza' not found in eat.php on line 5 >( ! ) Error: Class 'Pizza' not found in eat.php on line 5 Call Stack #TimeMemoryFunctionLocation ... See the Browser below for the full output.
As I already answered to your other comments, you just need to wait when the challenge is shut down, refresh the page so that the system create a new challenge instance for you and try again. It happens sometimes, though it depends on how you're using the system. Are you trying to open a few challenges at the same time in different tabs? Are you trying to solve it first or after the page is loaded you hit the Check button to see the error instead of trying to solve it? Please, share more details with us about how exactly you're using challenges and I'll be happy to check it further.
There were a couple times I tried hitting check to see if any errors show but the server kept crashing, so I stop doing that. I don't have challenges opened in more than 1 tab, so only working 1 challenge at a time.
What I have been doing now is try to solve it, then hit check and make updates if needed. Sometimes I have the answer exactly correct the first try and it shows the error. I verify its correct in the show answer section but it will still throw the error that doesn't make sense.
I see... Thank you for sharing more information about how you're using the challenge system. We will try to take a look to improve it. I can only suggest you wait until the challenge instance is shut down and restart the page to recreate a new challenge instance from scratch - it should work the 2nd time. Sorry for the inconvenience!
13 Comments
I miss the hint, that with the help of namespaces, you can have multiple classes with the same name, but in different namespaces and are able to reference them accordingly with the help of use statements and aliases, even on the same file:
Hey Ole,
Probably it was not so obvious. Yes, it's the way to avoid collisions with same class names. Thank you for sharing this tip with others!
Cheers!
good
It's very similar to packages in Java
Hey Herman,
Yep, exactly... the concept is not unique, and it's used in many programming languages actually :)
Cheers!
I'm not sure why I keep having error issues with some challenges. Its random. I tried 2 computers, 2 different browsers and I get this error for exercise 5 on this php namespace tutorial. Class Pizza and eat.php are locked and can't be edited. I've come across an error below like this before on another challenge.
Hey Terrence,
As I already answered to your other comments, you just need to wait when the challenge is shut down, refresh the page so that the system create a new challenge instance for you and try again. It happens sometimes, though it depends on how you're using the system. Are you trying to open a few challenges at the same time in different tabs? Are you trying to solve it first or after the page is loaded you hit the Check button to see the error instead of trying to solve it? Please, share more details with us about how exactly you're using challenges and I'll be happy to check it further.
Cheers!
There were a couple times I tried hitting check to see if any errors show but the server kept crashing, so I stop doing that. I don't have challenges opened in more than 1 tab, so only working 1 challenge at a time.
What I have been doing now is try to solve it, then hit check and make updates if needed. Sometimes I have the answer exactly correct the first try and it shows the error. I verify its correct in the show answer section but it will still throw the error that doesn't make sense.
Hey Terrence,
I see... Thank you for sharing more information about how you're using the challenge system. We will try to take a look to improve it. I can only suggest you wait until the challenge instance is shut down and restart the page to recreate a new challenge instance from scratch - it should work the 2nd time. Sorry for the inconvenience!
Cheers!
So it is the equivalent to packages in Java?
Hey Eduard
Yeah something like this :)
Cheers!
Thanks for the tutorial, great! Could you elaborate on the backslashes, though? Should it be 'use \...' or 'use ...' from inside a namespace?
Thanks, kept your 120 second promise :)
"Houston: no signs of life"
Start the conversation!