Page 1 of 1
How to switch from a C/C++ mentality to a PHP one?
Posted: Sun Sep 25, 2016 10:05 pm
by Giganitris
I don't know if this belongs in this section, I'm sorry if this should be in another subforum. Anyhow, I'm a C guy, and writing PHP is a struggle, because it requires such a huge shift in mentality. I don't really know what more to say. I'm going to look more into the reference and watch a few tutorials but damn, I'm so used to being given a small amount of tools in a library and using that to build bigger tools. Any advice or help?
Re: How to switch from a C/C++ mentality to a PHP one?
Posted: Mon Sep 26, 2016 12:21 am
by hybris
If it's any help there are tools for PHP too...
It took me 2 weeks to shift to PHP.
Sometimes I do get stuck and then I come here and the mods here are awesome!
I really like PHP now, I think its easy to model stuff fast using php/html...not so much code to get some visual results so atleast for me I get "feedback" faster from the code i make than in c and thats nice.
I started by doing a secure login (there is an excellent tutorial on the net for that) and when I was done with that I already gotten the feel for the language (that is if you dont just copy and paste the code

but actually type it and try to figure out what you do).
Good luck
EDIT: Check AJAX, JQUERY for tools
http://www.wikihow.com/Create-a-Secure- ... -and-MySQL
Re: How to switch from a C/C++ mentality to a PHP one?
Posted: Mon Sep 26, 2016 11:32 am
by Christopher
I think a C/C++ mentality will server you well with PHP. Plus the languages are very similar. Some of the big things you will need to change in your head are:
- No pointers. There references, but they are rarely used. And you don't allocate and free memory (don't try -- it only makes things worse).
- Scripting languages use include/autoload instead of header files, make, compile
- PHP scripts are short lived programs, so you need to adjust to the reality of building everything up per request and not freeing anything
- Shared nothing takes a little getting used to. As short lived programs, you reload the context/session each request. Yes weird, but it can be beautiful.
- The fact that PHP is mainly a HTML/CSS/Javascript generator means those languages are just as important to you as PHP.
- You can use Composer for your "small amount of tools in a library and using that to build bigger tools" approach.
There are more I am missing, but hopefully that gives you some ideas.