• CodeAcademy-like website to learn PHP?
    112 replies, posted
  • Hey guys, I've been wanting to refresh my (very little and basic) knowledge of PHP and actually get some work done, but truth be told, programming in general repulses me, however I've found that CodeAcademy.com has a "fun" approach to it and I could see myself sticking through it. As such, I'm wondering, does anyone know a website similar to it that teaches you PHP? Thanks.
  • honestly if I were you I'd take a detour straight past php and learn something else that language does more harm than good
  • [QUOTE=swift and shift;35476443]honestly if I were you I'd take a detour straight past php and learn something else that language does more harm than good[/QUOTE] The fuck? It's a wonderful language if used correctly.
  • [QUOTE=Floatation;35478716]The fuck? It's a wonderful language if used correctly.[/QUOTE] dont even bother arguing with swift, hes probably going to win eitherway
  • [QUOTE=Floatation;35478716]The fuck? It's a wonderful language if used correctly.[/QUOTE] it is [b]not[/b] a fucking wonderful language I'm really fucking riled up about this at the moment because just last week I had to figure out some really [b]fucked up[/b] issue that was causing us to lose data that paypal was sending us as an IPN postback so basically, paypal was sending us this payment data in windows-1252 encoding. now, php is oblivious to encodings and just pretends they don't exist (true story: all php strings are just stored as a binary buffer and a length in the interpreter) so we got the incoming data from paypal, and json_encode()'d it before saving it. Here's the fucking [b]kicker[/b]: PHP's json_encode() [i]expects[/i] that all the strings you give it are encoded in UTF-8. There's nothing you can do to change that behaviour at all. So we were getting a bunch of payments coming through with random nulls strewn through the JSON. Nothing was written to PHP's error log or anything so we had no fucking clue what was happening. After doing exhaustive logging on the production machine, I noticed that all the lost data happened when a user had an accented character in their full name. This broke everything because accented characters in windows-1252 (which is a one-byte-per-character encoding) have their codepoints between 128..255. UTF-8 (which is a variable length encoding) uses the most significant bit of the first byte in a character to determine if it's multibyte or not. So these accented characters when treated as UTF-8 data by PHP were seen as malformed. The dirty solution was to insert calls to utf8_encode() all through the IPN handler. This works for the time being, but we're going to be [b]fucked[/b] if PayPal ever starts sending data in UTF-8 or any other encoding that isn't compatible with windows-1252. In 2012, it is no longer fucking acceptable for a language to not care about encodings. Languages need to be [b]encoding aware[/b] and they need to do proper conversion for you to ensure you don't lose data. Most modern languages keep track of which encoding each individual string is in and will automatically convert the encoding if required. PHP makes you take this bullshit into your own hands. PHP's encoding support is so fucking haphazard that you need to be [i]really careful[/i] when doing anything on strings if you want to make sure you don't fuck up. This is especially critical when you're writing code that handles transactions. If you don't believe me on how fucked up PHP's encoding support is, check this page: [url]http://www.phpwact.org/php/i18n/utf-8[/url]. [b][i]That[/i][/b] is one of the many reasons why one should not use PHP. [editline]8th April 2012[/editline] I should also note that I patched PHP's implementation of json_encode and sent a pull request. Basically it amended the behaviour so that instead of just returning null if it encountered an invalid UTF-8 string, it'd treat the input as ASCII and try again. This would've saved our asses. When I sent in the patch, I got a response from Rasmus Lerdorf himself basically saying "no this behaviour is not a bug, please go read the JSON spec, it states all strings shall be UTF-8". That's a ridiculous response because while he may be technically correct, it really doesn't help if you have functions in a non-encoding-aware language that expects its input to be in a certain encoding, especially if all the data in $_GET, $_POST, etc. is [b]not[/b] in UTF-8. [editline]8th April 2012[/editline] Also, if you don't believe me, try doing json_encode("\x80") and see what happens.
  • I've encountered that paypal issue before. You can tell the paypal IPN that you want UTF-8 responses which makes everything 10x easier FYI.
  • [QUOTE=Catdaemon;35481737]You can tell the paypal IPN that you want UTF-8 responses which makes everything 10x easier FYI.[/QUOTE] It's still something that shouldn't even be an issue in the first place
  • [QUOTE=swift and shift;35482348]It's still something that shouldn't even be an issue in the first place[/QUOTE] It depends really, the root of the problem is that you don't know php properly. It's like making this complaint about C++ - you should know better. Once you realise the language has limitations you can work with them using the provided tools. With some other languages, it might automatically convert the character encoding which is just as disastrous if you're not expecting it. All gateways like paypal's IPN let you specify the type of data you want, and you know what they say about assumptions. Does json_encode not throw a warning when you try to use it with the wrong type? I'd say that's the real issue here. There are many cases where php is great. I use it for most of my projects because I'm familiar with it and it causes me no issues. Where it falls down is beginners making silly mistakes because they haven't made an effort to learn it properly. I don't think that's a reason to tell people not to learn it at all though, as it's one of the most important and widely used languages for web development.
  • [QUOTE=Catdaemon;35482481]Does json_encode not throw a warning when you try to use it with the wrong type? I'd say that's the real issue here.[/QUOTE] The real issue is that the string is not the wrong 'type'. PHP has no idea what encoding anything is, and there's no way to tell it. Then you have a bunch of different string functions, all operating on different encodings, with the encoding of any given string known only by the developer. That's the issue.
  • I doubt big websites would use bad languages. Stop trying to force your opinion to other people. You sound like one of those apple fanboys who are complaining about bluescreens in windows. If you don't like to use something it doesn't mean it's bad.
  • [QUOTE=Miljaker;35482926]If you don't like to use something it doesn't mean it's bad.[/QUOTE] It's the other way around. He dislikes it because it's bad.
  • I think it's just a temporary facepunch cool-thing to dis PHP. One of the many reasons I am not active here.
  • [QUOTE=Floatation;35483092]I think it's just a temporary facepunch cool-thing to dis PHP. One of the many reasons I am not active here.[/QUOTE] PHP is [b]not[/b] a good language. If you want to use a horrible language with fallacies all over then be our guest. [editline]9th April 2012[/editline] [QUOTE=Miljaker;35482926]I doubt big websites would use bad languages. Stop trying to force your opinion to other people. You sound like one of those apple fanboys who are complaining about bluescreens in windows. If you don't like to use something it doesn't mean it's bad.[/QUOTE] The only big website that really uses PHP is Facebook and it's been incredibly hard to scale and maintain. [url=https://github.com/facebook/hiphop-php]They've even had to rewrite the entire language.[/url]
  • [QUOTE=Jelly;35483327]PHP is [b]not[/b] a good language. If you want to use a horrible language with fallacies all over then be our guest. [editline]9th April 2012[/editline] The only big website that really uses PHP is Facebook and it's been incredibly hard to scale and maintain. [url=https://github.com/facebook/hiphop-php]They've even had to rewrite the entire language.[/url][/QUOTE] Pretty sure Wikipedia also uses PHP.
  • Since when does CodeAcademy.com even teach PHP? I thought they are only JS, HTML, and CSS?
  • [QUOTE=Catdaemon;35482481]I don't think that's a reason to tell people not to learn it at all though, as it's one of the most important and widely used languages for web development.[/QUOTE] The reason isn't because beginners have an easy time fucking things up in PHP, it's because there are a lot of solutions out there that are way better in pretty much every aspect.
  • yahoo wordpress facebook wikipedia digg php is the most used language out there. If it was bad people would have stopped using it by now. Just because some languages are better for some things doesn't make php a bad language.
  • [QUOTE=Miljaker;35483631]yahoo wordpress facebook wikipedia digg php is the most used language out there. If it was bad people would have stopped using it by now.[/QUOTE] Let's not forget that Facepunch is using php :]
  • [QUOTE=Miljaker;35483631]yahoo wordpress facebook wikipedia digg php is the most used language out there. If it was bad people would have stopped using it by now.[/QUOTE] Just because a lot of people use something doesn't mean it's the best solution. There's a lot of young earth creationists out there still, but that doesn't give any validity to their beliefs. If you're so ready to defend PHP have you actually spent any even remotely significant amount of time with the alternatives? Have you used any of the alternatives in commercial projects? Have you worked on anything even remotely large scale with any of the alternatives?
  • [QUOTE=KmartSqrl;35483813]Just because a lot of people use something doesn't mean it's the best solution.[/QUOTE] I never said it was the best solution. And I looked into other languages but didn't see much that would benefit me. I do plan on learning other languages in time because I'm interested in them and knowing more can never hurt. The problem I have is that a lot of people here are trying to "force" other people into learning something different then php. And I simply disagree with that attitude. [editline]8th April 2012[/editline] First 5 vacancy I found (when searching "webdevelopment") in one of the largest vacancy sites in the Netherlands have the following requirements: 1. HTML, My SQL, PHP, XML. 2. PHP & MySql required, Javascript, Ajax and HTML big pre 3. PHP required, XHTML/CSS basics 4. PHP, MySQL, HTML, CSS, Javascript and jQuery 5. .NET and SQL And then some people say "skip learning php, the language does more harm then good" PHP might not be the best language out there but it certainly isn't bad. And I dare to say it's one of the most important languages to learn.
  • [QUOTE=Knallex;35484960]going to be wonderful when php gets phased out and replaced with something like ruby[/QUOTE] PHP is an industry standard. For better or for worse, that will [b]never[/b] happen. That's the main reason it's worth learning if you're after a career in this field. Rails job postings are few and far between (although usually higher paid), PHP job postings are EVERYWHERE.
  • There are so much competition with PHP that it's not even worth learning if you want a job later on. [editline]8th April 2012[/editline] The only reason why I use PHP is because I don't know anything better. And I've tried to learn Python & ruby but I didn't have fun learning it as PHP.
  • [QUOTE=Miljaker;35482926]I doubt big websites would use bad languages. Stop trying to force your opinion to other people. You sound like one of those apple fanboys who are complaining about bluescreens in windows. If you don't like to use something it doesn't mean it's bad.[/QUOTE] Selection bias. Big websites aren't big because they use PHP. The only reason that 'most big sites use PHP' is that most sites use PHP. lrn2statistics
  • I like PHP more then Python, I say this cause I've been using Python at work and I'm upset about it :saddowns:
  • If you like PHP then just silently disagree with swift, you will never convince swift that PHP can be used in production, eventhough it has been proven worthy through the last decade. How long would it take you to write a wrapper function for json_encode, that checked encoding and changed it properly before json_encoding it?
  • [QUOTE=swift and shift;35489340]Selection bias. Big websites aren't big because they use PHP. The only reason that 'most big sites use PHP' is that most sites use PHP. lrn2statistics[/QUOTE] I never said they are big because they use php. I'm saying that if php was as bad as you make it sound those big websites would have stopped using it a long time ago.
  • [QUOTE=reeferdk;35493834]How long would it take you to write a wrapper function for json_encode, that checked encoding and changed it properly before json_encoding it?[/QUOTE] that's the problem, you can't "check" encoding in PHP because strings are just binary buffers. The best you can do is attempt to guess the encoding.
  • [QUOTE=swift and shift;35494656]that's the problem, you can't "check" encoding in PHP because strings are just binary buffers. The best you can do is attempt to guess the encoding.[/QUOTE] Isn't the issue here that you were totally clueless of the limitations of the language and the encoding in which you recieve your data? PHP certainly isn't the only language who use bytebuffers as strings, and even those who has decent string structures tend to mess up when you mix character encodings. The real issue here is a developer totally unaware of the enviroment in which he is acting.