ejaboneta Posted October 4, 2009 Share Posted October 4, 2009 Excuse my ignorance but I'd like to know the differences between scripting in php and C++. I do realize the obvious differences in php being interpreted and C++ being compiled. I'd just like to know how hard it would be for me to start learning C++ only having scripted in PHP. I've read that PHP is based on C/C++. Quote Link to comment https://forums.phpfreaks.com/topic/176465-php-vs-c/ Share on other sites More sharing options...
Mchl Posted October 4, 2009 Share Posted October 4, 2009 Only syntax is similar and not entirely. You'll be learning a lot of new concepts. It won't be straightforward move for sure, but it shouldn't be very hard as well. Quote Link to comment https://forums.phpfreaks.com/topic/176465-php-vs-c/#findComment-930183 Share on other sites More sharing options...
corbin Posted October 4, 2009 Share Posted October 4, 2009 It will be harder than you'll think, but as long as you're willing to spend lots of hours going "WTF?!" you'll be fine . Quote Link to comment https://forums.phpfreaks.com/topic/176465-php-vs-c/#findComment-930307 Share on other sites More sharing options...
RichardRotterdam Posted October 5, 2009 Share Posted October 5, 2009 I've read that PHP is based on C/C++. PHP is also written in C But anyway C/C++ are lower level programming languages. It's closer at hardware level. OOP in C++ can be a bit confusing (at least it was to me) at first since you don't encapsulate the methods in the class like PHP and Java. If you're only familiar with PHP, working with pointers will be completely new to you. This is were you can screw up big time because you can create memory leaks if you don't use pointers correctly. Quote Link to comment https://forums.phpfreaks.com/topic/176465-php-vs-c/#findComment-930611 Share on other sites More sharing options...
corbin Posted October 5, 2009 Share Posted October 5, 2009 "OOP in C++ can be a bit confusing (at least it was to me) at first since you don't encapsulate the methods in the class like PHP and Java. " Errr.... What do you mean? Quote Link to comment https://forums.phpfreaks.com/topic/176465-php-vs-c/#findComment-931119 Share on other sites More sharing options...
RichardRotterdam Posted October 5, 2009 Share Posted October 5, 2009 "OOP in C++ can be a bit confusing (at least it was to me) at first since you don't encapsulate the methods in the class like PHP and Java. " Errr.... What do you mean? Hmm that was vague I guess. Just took a code sniplet of wikipedia to clarify. class person { std::string name; int age; public: person() : age(5) { } void print() const; }; void person::print() const { cout << name << ";" << this->age << endl; /* we don't have to mention what "name" and "age" are, because it automatically refers back to the member variables. The "this" keyword is an expression whose value is the address of the object for which the member was invoked. Its type is const person*, because the function is declared const. */ } The "print" method is after the last curly bracket while the print method is declared public between the curly brackets. That was pretty much the first time I'd seen this. Quote Link to comment https://forums.phpfreaks.com/topic/176465-php-vs-c/#findComment-931135 Share on other sites More sharing options...
corbin Posted October 6, 2009 Share Posted October 6, 2009 Oh..... I wouldn't call that encapsulation... Prototypes have nothing to do with the term "encapsulation", but I see what you meant. Quote Link to comment https://forums.phpfreaks.com/topic/176465-php-vs-c/#findComment-931166 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.