News for hackers. Stuff that matters.
Re:PHP Apprentice – An online, open-source book for learning... by tangue on Friday January 11, 2019 @11:14AM (#18884467)
Nice job and well written. A nice addition would be how to use pdo. I'm appalled by the number of ressources I see online which are using the old mysql api.
Re:PHP Apprentice – An online, open-source book for learning... by meritt on Friday January 11, 2019 @11:27AM (#18884574)
> I'm appalled by the number of ressources I see online which are using the old mysql api

Recently authored articles? We have an internet filled with 20 years of PHP tutorials, and unfortunately for beginners there's not an easy way to evaluate if something utilizes modern best practices or is an Experts Exchange post from 2001.

Re:PHP Apprentice – An online, open-source book for learning... by mattigames on Friday January 11, 2019 @11:41AM (#18884691)
I find strange you can't down-vote a link on Google, it should exist and Google should take it into account specially for technical links (less so for opinions articles or anything political)
Re:PHP Apprentice – An online, open-source book for learning... by jordigh on Friday January 11, 2019 @12:20PM (#18885006)
Everything is political. I wouldn't want people to downvote Mercurial links into oblivion.

Anyway, Google links are pretty much already ordered by popularity.

Re:PHP Apprentice – An online, open-source book for learning... by mattigames on Friday January 11, 2019 @12:29PM (#18885086)
That's the problem, in technical links popularity (as in number of visits) is not linked to correctness, that's one of the reasons StackOverflow is so useful, because the top-voted answer is like 99% of the times the most correct (useful) one.
Re:PHP Apprentice – An online, open-source book for learning... by ysleepy on Friday January 11, 2019 @01:26PM (#18885599)
Except when that answer is 5 years old and is as wrong as the ExpertsExchange post from 2001.
Re:PHP Apprentice – An online, open-source book for learning... by ceejayoz on Friday January 11, 2019 @01:41PM (#18885740)
Unlike EE, though, any user can propose an edit to that now-incorrect answer (or just edit it outright, if they have 2k rep).

A nice big "this answer is outdated, see [other answer]" note does wonders.

Re:PHP Apprentice – An online, open-source book for learning... by JeremyBanks on Friday January 11, 2019 @02:18PM (#18886034)
Unfortunately, such edits are rarely accepted. The intent was for the site to be more wiki-like, but these days "respect the author's intent" is the prevailing wisdom. The cases where someone edits a top answer with a significant correction or update are very few, and require overwhelming community support or they'll be reverted.

This is particularly distressing in the case of security vulnerabilities. Vulnerable code being copied from Stack Overflow into consumer applications isn't hypothetical, it's been empirically demonstrated (https://www.aisec.fraunhofer.de/en/stackoverflow.html), yet the community and company refuse to accept responsibility and address the problem. (Of course the developer creating the application is more responsible, but Stack Overflow is in a position where they could help protect innocent end users and the common good.)

Pinning of accepted answers to the top of the list was a good idea when the site was young. These days, it prevents updated better answers from taking the place of ten-year-old misinformation.

Re:PHP Apprentice – An online, open-source book for learning... by bpicolo on Friday January 11, 2019 @06:04PM (#18888058)
Built-in SEO gaming would be a weird feature
Re:PHP Apprentice – An online, open-source book for learning... by prophesi on Friday January 11, 2019 @11:38AM (#18884663)
Yep, the plethora of out-of-date resources is what I'd place as the main issue with PHP today. I usually steer people to use the Laravel framework since it makes it difficult to write bad/dangerous code.
Re:PHP Apprentice – An online, open-source book for learning... by settler4 on Friday January 11, 2019 @11:15AM (#18884473)
This is a very good resource for PDO: https://phpdelusions.net/pdo
Re:PHP Apprentice – An online, open-source book for learning... by ademup on Friday January 11, 2019 @12:15PM (#18884961)
https://phpdelusions.net/pdo has done a very thorough job of covering PDO IMO and makes a fantastic companion to https://phptherightway.com/.
Re:PHP Apprentice – An online, open-source book for learning... by restoreddev on Friday January 11, 2019 @11:56AM (#18884812)
PDO is definitely on the list. There are very few resources for it.
Re:PHP Apprentice – An online, open-source book for learning... by ocdtrekkie on Friday January 11, 2019 @11:33AM (#18884621)
Can confirm. I've written one site with PDOs and a lot of sites with the old stuff. PDO is definitely a different feel to wrap around, and more resources on it would definitely be good.

For what it's worth though, my understanding is mysql_ functions are removed completely as of PHP 7. So that old documentation will just not work, rather than teaching people the least secure option of how to write their website.

Re:PHP Apprentice – An online, open-source book for learning... by evunveot on Friday January 11, 2019 @06:15PM (#18888134)
You're right, but you can just replace mysql_* with mysqli_* if you're so inclined.
Re:PHP Apprentice – An online, open-source book for learning... by mgkimsal on Sunday January 13, 2019 @09:21AM (#18896760)
that doesn't work.

mysql_query($sql, $link);

mysqli_query($link, $sql);

Re:PHP Apprentice – An online, open-source book for learning... by Aeolun on Friday January 11, 2019 @10:41PM (#18889470)
I’ appalled that my 10 year old website recently suddenly broke because someone updated PHP to 7.2.

Then I realized it was pretty amazing that it lasted that long in the first place.

Re:PHP Apprentice – An online, open-source book for learning... by mgkimsal on Saturday January 12, 2019 @12:23PM (#18892161)
similar. got a call from someone re: a site built on a homegrown mvc framework from 2000/2001 (when PHP4 was just out).

this call came in late 2017 saying "hey, we migrated the site and it doesn't work". There was some change in PHP5.6 and the initial PHP4 code had some "by reference" class stuff that wasn't working any more. It was a small change to get it working again, but there was enough PHP4 in it that a move to PHP7 wasn't going to work without a lot of work. I'd suggested a rebuild, which... wasn't too well received. Pointing out that they'd had 16 years of functionality on a web codebase (with no other costs) was probably as much ROI/value as you'd ever be able to get out of anything.