Differences and Similarities between PHP and C#
Differences
• C# is a strictly typed language unlike PHP but PHP can be made strongly typed by using within script tag.
declare(strict_types = 1);
• C# is compiled while PHP is interpreted at run time.
• Variables are represented by preceding $ sign in PHP while they are written without any symbol in C#.
• Function is written with function keyword in php while in c sharp it is without function keyword.
• function names are not case sensitive in PHP. This is a peculiarity of PHP.
• foreach loop syntax is different, in c# we have foreach (type element in array) while in php we have foreach(array as element)
• Concatenation operator is . in php and + in c sharp.
• const is define by const keyword in c# and define keyword in php.
• Class object or method is called by using object->property/method in php while in C# its object.property/method.
• Array built in methods are more rich in PHP than C#
Similarities
• Comments are done sameway i.e. /*.. */ for block comments and // for single line comment.
• Echo, print_r and var_dump are used for printing and debugging while Console.WriteLine is used in c sharp.
• Logical operators are pretty much the same.
• Variable names are case sensitive in both languages.