C++ -- PHP

Started by
20 comments, last by ToohrVyk 16 years, 6 months ago
I have currently started learning C++, because I want to become a game developer in the future. I have some knowledge of the basics, which I've learnt in 2 months. Now my boss wants me to learn PHP, which is quite needed when making website's he says. I'll have to let my C++ down for some time, to learn PHP. Although I heard then when you learn other languages before C++, C++ will beocme a lot easier. Is PHP counted as one of those languages? Is PHP a good first step to C++, with the unnatural syntax and so? Second, does anybody know a good place or book to learn PHP from. I'd like to learn it in 2 weeks at highest, I don't need to know it perfect, as long as I am al right in it and know the most important things of the language. I heard PHP is not a super big language, so I must be able to do it. I got 8 hours a day, 5 days a week. If it will take longer, please tell me so with it. Thanks! Marlon.
Advertisement
Personally I wouldn't know if learning other languages would make C++ easier, but for me learning C++ made learning other languages easier.

C++ and PHP syntax are fairly close so all you'll need to do is figure out what does what in PHP.

I presume you know how to setup a web server with PHP support or already have one, if not you might want to look into that first. At least be able to run a web server on your local machine, makes testing a lot easier.

It took me about a week to learn the basics of PHP and a while longer to get good at it. I am still learning new things every day.

If your boss wants you to learn PHP he might also want you to integrate it with a database, a lot of people use MySQL, so you'll want to look into that as well.

I mostly learned from online tutorials, examples and references. The best site to begin for me was: Tizag

Hope this helps.

PS Later when you're good at PHP and MySQL and you want to have some more on your plate, look up SQL injection. But I'm getting ahead here, just leave it for later.
Try, try and fucking try again.
The best place for PHP information is their own website, PHP.net (I recommend downloading the extended CHM help file).

The basic language is quite straightforwards (and "C-like" as far as curly-braces go), and there is an extensive library of built-in functions. Most functions have user-submitted notes with good examples and important caveats documented.

All I can recommend with PHP is to make sure that both register_globals and magic_quotes are disabled as these will do unexpected and awkward things with variables and data, the latter lulling people into a false sense of security as far as SQL injections and data escaping goes.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Many people are telling me that learning C++ without having any programming experience is going to give you a hard time. Do you think the hard time will be less hard when you've learnt PHP before C++ ? If so I think I'm going to do that. I am someone with a lot of perseverance, but I don't want to take any risks. My dream is to become a game (or software) programmer in C++, and I will go for that. I just don't want to take any risks, security is important. I have 2 months of C++ programming experience, and it's going quite well. Haven't done anything of the syntax though, and that's what people are warning me about, because it's so unnatural. I'm going to get there, no matter what it takes. I just like security.
In my oppinion, learning PHP would be very helpful.

Getting to know php is not very difficult, and as the previous poster said, the syntax is very familiar.
Get familiar with variables, functions, loops, arrays, etc..

Then the only real transition to c++ will be the variable 'type' and pointers.
Then again i read though the entire PHP documentation before learning c++, i can only speak of how my friends struggled with the types when learning ;)

Quote:Original post by marius1930
In my oppinion, learning PHP would be very helpful.

Getting to know php is not very difficult, and as the previous poster said, the syntax is very familiar.
Get familiar with variables, functions, loops, arrays, etc..

Then the only real transition to c++ will be the variable 'type' and pointers.
Then again i read though the entire PHP documentation before learning c++, i can only speak of how my friends struggled with the types when learning ;)



Thanks for your reply! I like C++ a lot, and if I start PHP it will only be a step of my way to C++, because C++ is the language I want to program with in the end. I like PHP a lot too though, because you can make web site's with it that look really good. I'm someone that likes making website's, so if I can take my first step on the way to C++ (actually second, because I've been busy studying the C++ basics for 2 months now) while keeping myself busy with some of my hobby's that would be great. As long as it will help me getting closer to my future goal, programming with C++, I am going to do that. Can anyone assure me that?

Ok, before I reply, I got a question and something to say. I am someone that needs a very clear way to work myself to my goal, so if I'm going to learn PHP, I can't learn it from a web site, because that is like 'a little bit here, a little bit there'. I like to learn it in a good way, I like to have a clear plan, like a book or like a course. I hope you guys understand that, and hopefully someone can help me with that.

I'd like to be sure that if I start learning PHP it will be of good use for my future goal, programming in C++. So if someone can assure me that with a rather good explanation I would be very grateful, and otherwise I'm going to stick to C++.

Thanks for all your help though. The guy that helps me with this will get a 'extremely helpful and friendly' vote from me.

Thanks in advance!
Hey Marly,

Quote:Original post by Marly
Is PHP counted as one of those languages? Is PHP a good first step to C++, with the unnatural syntax and so?

I'm studying computer sience at the university and we are only tought Java. Java is an object-oriented lanquage and the professors expect us to, if we are able to do java, we can do any oo lanquage. I do think PHP is not really loved for the oo. More over it hasen't been (good) oo since PHP 5. Also, php is not really a programming language who is very strict about your syntax (wile Java and C++ are). Also you almost don't get very good introduced with types. Next to these points, php is a language for Web Aplications, while C++ is a programming language for all sorts of applications.

A better step up between PHP and C++ would be Java or C#. Java and C# are almost identically to each other in syntax, but Java is cross platform while C# is a .Net language.

--
GBS

[Edited by - GraphicsBas on September 20, 2007 1:39:11 PM]
GBS
I would say learning several languages is not a problem at all. Infact you will probably be learning several languages sooner or later anyway.
The bottom line is of course to choose one language and stick to it until you are comfortable using it before starting another.
As someone said PHP is and is meant to be C like.
The idea with PHP always was that a C programmer should be able to jump right into it.
The difference between C and C++ is not the syntax, but rather how you organize your code, data and ideas. C++ has some new syntax/semantics to accomodate this that was not present in C. Commonly referred to as Object Oriented Programming (OOP)
After C++ and OOP became "the norm" PHP has picked up on that as well and now offer the same syntax/semantics needed to program in a object oriented way, so its all good =)

Personally, if I had 2 weeks to get familiar with a language I would consider buying a book from O'Reilly. Even if their books is not the best, they will get you wet and they are cheap and easy to follow.
Don't learn PHP (I know you have to, but still ;-)!

I've been a web developer for about 10 years now and I've written my first line of PHP code probably around 1998. But, despite the fact that I've used PHP for a long time, I still think it's a terrible language (I actually like it to some degree, but I like it the way you like a car you've had for many years that constantly breaks down on the freeway).

Here's a couple of reasons why PHP is a bad language for you to learn:

- The syntax is a mixture of C, Perl and Java (and usually just the crappy parts of each of these languages)
- PHP doesn't have a namespacing system, yet it has > 2000 built-in functions (that all reside in the same global namespace)
- PHP's built-in functions don't share a common naming convention and parameter orders are more or less random
- Even if you decide not to use global variables, PHP will already have a whole bunch of those registered before you even write a single line of code (and I'm not talking about the register_globals kind of global variables)

The most important reason however is, that PHP promotes bad coding practices. Now you can't attribute that directly to the language, but if you haven't done much coding before, PHP can easily spoil you for life.

If you have a chance to learn something else, go for Ruby or Python.
I don't think PHP will help a lot with learning C++, but that's just my opinion.

Before this comes up: Why is PHP so popular if it's such a bad language? Because it's free, because it replaced Perl which was even worse, because it promotes sloppy coding and a lot of people know nothing else, because it has everything you'll ever need already built-in, ... lots of reasons ... but not because it's a particularly nice language.
Quote:Original post by Marly
Many people are telling me that learning C++ without having any programming experience is going to give you a hard time. Do you think the hard time will be less hard when you've learnt PHP before C++ ?

Somewhat.

If you learn PHP, you will have learned a lot of basics about programming and problem solving, as well as norms of C-like languages and imperative constructs. All of that will be reused in C++ (among many other languages).

Quote:I am someone with a lot of perseverance, but I don't want to take any risks.

Then you're doomed to failure. Risk is a prerequisite of success. Besides, you're not going to be any kind of good programmer if you don't learn multiple languages. Knowing C++ is not enough. I've used C++, Perl, Python, VBScript, VBA, C#, VB6, C, JavaScript and declarative languages like XML/XSL/XSLT/XSD, CSS and HTML for work. When I worked in the game industry (not a programmer), the programmers at our shop used Java and Shockwave in addition to C++.

Quote:I just like security.

So did C programmers of the 70s and early 80s. So did COBOL programmers of the 60s, 70s and 80s. So did Java programmers of the 90s. So do the current crop of .NET programmers. It's a false notion. Your tools will change if you stay in this business for over 5 years. Get comfortable with the notion.

Quote:Original post by GraphicsBas
Java and C# are almost identically to each other in syntax, but Java is cross platform while C# is a .Net language.

That makes no sense. Java is a JVM/Java runtime language. The runtime/VM has been ported to several platforms, just as the .NET runtime has been ported to several platforms - Mono is an independent implementation for Linux, now with a formal cooperation agreement with Microsoft, and Microsoft itself provides a Shared Source implementation for BSD called Rotor.

So, really, there's no difference between Java and C# in terms of approach to platform support.

Quote:Original post by pulpfist
The difference between C and C++ is not the syntax, but rather how you organize your code, data and ideas. C++ has some new syntax/semantics to accomodate this that was not present in C. Commonly referred to as Object Oriented Programming (OOP)

The differences between C and C++ extend far beyond object-oriented programming. There are differences in language spec guarantees as to defined behavior, differences in idioms, massive differences in standard library provisions, differences in support for programming paradigms (C++ provides some syntactic support for generic and functional programming in addition to object oriented, whereas C is fully capable of expressing all of them but requires you to author the mechanisms yourself), among others.

Quote:Original post by Harry Hunt
[PHP] replaced Perl which was even worse...

Whoa, now! Perl has had a namespacing mechanism, for example, for years. Perl is better than PHP in every measurable way except immediate comprehensibility to beginners/unfamiliars. Once you understand how Perl works, you realize that it is an incredibly powerful, feature-rich language with an extensive collection of freely available extension modules (CPAN - all of which are organized in packages, which is Perl's namespacing mechanism, but also more than that: packages are lexical scope).

Yes, it's "ugly." But it can trivially do some things that would reduce your brain to gibbets.

This topic is closed to new replies.

Advertisement