Going from C# to php [closed]
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this questionI'm going to have to learn php soon, because I need it for a new job. Up until now, i've always programmed in C#. Are there things I should know about php that are strange or different from a C# perspective? Things to look out for?
They’re different programming languages. But you can do with php most things, that you can do with C#. I think they`re different in next ways:
- PHP is more simplier than C#.
- C# is full OOP language, but PHP is not.
- .NET library of classes is very big and you have all that you need. If you are using PHP, you can download classes from pear at official php site or from zend framework official site.
- If you create web application in C# you use ASP.NET MVC 2 and in PHP you can use less powerfull frameworks: symfony, zend framework, yii, kohana.
You will feel very limited with PHP after C#.
Books to read:
- PHP 5 for proffessionals.
- PHP Design patterns.
Current version of PHP is 5.3.
completely different, but a lot easier! Grab some PHP books: PHP MySQL books
Bookmark php.net/manual/en/, Join an IRC: irc.phpfreaks.com, Learn a framework alongside: CodeIgniter, Get a WAMP/LAMP setup, start on a project asap and generally have fun.
:) Welcome to PHP
The most important URL when learning PHP is definitely http://www.php.net/manual/en/
The way you use C# and PHP is different. Using PHP you will have to write more yourself, but that will give you the advantage of having more control. The syntax itself is pretty similar, so the only thing you'll miss is the .NET framework. The weak typing is a bit odd when coming from a strong typed environment, but you'll get the hang of it.
Unlike previous comments, PHP can be OO (http://php.net/manual/en/language.oop5.php). Just read a lot and try to use good practices as you do when programming in C#.
At the moment this comes to my mind:
- PHP is a loosly typed language (you do not have to declare variables, functions, objects prior their use)
- in PHP you need to have "function" in the declaration.
- In PHP you implement interfaces using "implements" (in C# with ":")
PHP was designed specifically to make webpages, and was also put together to be as easy as possible, but without looking too far into the future or being too tied to the past.
C# was designed to do anything, and run anywhere .NET is installed. It's put together to be as complete as possible, and draws more from the past.
PHP is easier. If you've learned C#, don't worry; PHP should be quick for you. Find example code so you can see how things are typically done, bookmark the PHP Manual, and dig in.
Strangest thing about PHP for you would be: You don't need "windows" or ".net framework" to code :)
You can grab and notepad or any editor or even online one, write code, and save. Voila!
PHP is strong in OOP too (PHP 7 being amazingly cooler now).
So for web apps mainly, PHP will be all that you might be needing!
However if you have strong background in c#, you should try continuing with it.
But still give PHP 10 days, so that you realize its depths.
As for me C# is valuable not because of language but more of a framework you can use with it. So in that sense PHP is totally different from C#.
I've been working in PHP for some time and then moved to C# and ASP.NET. And now there is no way someone can drag me to PHP again. I would prefer looking for another job rather that working in PHP. Nothing personal, and possibly I am too dependent on IDE but I won't trade Visual Studio's IntelliSense, C#'s strong typing and a lot of other features I love about .NET in general.
I have been using php for more than 10 years now and learned C# when it was put on the market and use it ever since.
I think PHP is a very powerful language that can be very well structured if the programmer has driven to be organised and thorough. Undeniably PHP doesn't give you the ease of a framework (EDIT:unless you implement one). C# with .NET framework does a lot of things for you, whereas in PHP you often need to write your classes yourself.
There are gigantic class libraries on the net where you could find almost everything that you would ever want, however implementing them is sometimes more challenging compared to the highly sophisticated assemblies of .NET.
I think there is a huge market for PHP with all the UNIX platforms in use, however there is a new candidate in the horison with RUBY on Rails which has a lot mor in common with C# (I think).
Why did you decide to go with PHP?
精彩评论