Those systems have a lot of lines of code. Both of them have multiple developers, it's not an easy project. The best way to learn php is by reading tutorials and trying stuff out. To make something like that you need to know both php and mysql (or an alternative database)
Developing any of these system will take weeks of dedicated time and lots of experience. Try looking at example simple CMS codes to get what the coding looks like after you read some tutorials.