Issue
Why would you leave the open and close brackets in the code without the condition first? I've seen examples in C# where the code does compile when you have something like this:
{
Console.WriteLine("Hey");
}
Is this just bad syntax? or something else?
Solution
New brackets means new scope. For example if you want to create variable, which should exists only in specific part of code you can surround it with brackets:
{
var a = 1;
{
var b = 2;
//here 'a' and 'b' exist
}
//only 'a' exists
{
var b = 2;
//again 'a' and 'b' exist
}
//again only 'a' exists
}
Answered By - MagliaRosa Answer Checked By - Mildred Charles (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.