PHP Apprentice – An online, open-source book for learning PHP
phpapprentice.com
phpapprentice.com
The site is cleanly and beautifully formatted and I love how lightweight it is: HTML files, a CSS file, a JS file and an image. It’s such a refreshing change from the thousands of visually cluttered sites that make hundreds of resource requests (most of them third-party) and whose content is not visible without allowing third-party JavaScript. When I completely disabled JavaScript on this site, all I noticed were non-essentials such as Solarized syntax highlighting and the Table of Contents; I could still navigate through the site using the Previous and Next links (and of course, the browser’s Back button).
Kudos!
There’s a lot of arguments, I just don’t think they’re particularly good.
Don’t misunderstand me, there is a point there, but it’s buried under a load of text.
Thank you in advance, it's much appreciated.
I'm learning symfony framework after my micro framework of choice lost its support (Silex..).
The symfony documents are ok, but I wouldn't want to give them to someone starting out. (though looking again, they seem better..) https://symfony.com/doc/current/page_creation.html
Someone showed me the free video cast howto build a basic symfony site. I though it was pretty good. Like many of these, the basic tutorials are free, but its a subscription site.
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.
Anyway, Google links are pretty much already ordered by popularity.
A nice big "this answer is outdated, see [other answer]" note does wonders.
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.
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.
mysql_query($sql, $link);
mysqli_query($link, $sql);
Then I realized it was pretty amazing that it lasted that long in the first place.
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.
class A {
public int $id = 0;
public ?Foo $somefoo;
}
The language has evolved slowly but surely, and it's now much harder to make obvious mistakes thanks to a bunch of good-quality static analysis tools (one of which I authored).There's still artifacts of past PHP versions that are there, though, which makes it far less nice to use than something more modern.
Later versions of PHP 5 were worlds apart from version 4.
Having skimmed through several of these chapters, though, I just feel like it’s too similar to the official PHP docs, even down to the TOC.
Wouldn’t it have been better for everyone to put this effort into improving the docs, rather than developing yet another book in a silo that likely won’t have the longevity we’d like?
FWIW, I don’t think giving a more readable aspect to the official docs would be bad. It’s already got way more of that feel than it did in PHP 4, when it had more of an MSDN auto-generated parameter documentation feel. With the clear sections and code snippets I think both could be achieved with little extra effort.
Is there a better language built for rapid web application development. You could debate which is better rails/laravel but in 2019 I would learn php.
You may suggest Go, python, .net, node, Perl or java. They could be used but each only offers an advantage in certain situations and make development slower or have another disadvantage.
If you want to make a website using php is the simplest easiest fastest choice available.
The ‘quick and very dirty’ parts are still there, the ‘clean and efficients’ bits have been added, and there’s a ton of still runnable doc and code lying around.
All of that is a blessing and a curse of course, but I think that makes it a unique proposition.
$name = $_GET['name'] ?? $_POST['name'] ?? "unknown";
In the arrays section, I'd also introduce the $array[] shorthand for array_push(), i.e: $array[] = $new_element; .menu {
margin-bottom: 1.5em;
position: sticky;
top: 0;
z-index: 1000;
background: #fff;
padding: 10px;
}Thanks for publishing this op!
No wonder PHP developers have a bad reputation.
Example: "Why do you use double quotes everywhere?" Most probable answer: "Because I can use variables and the backslash-n thingies everywhere and its more convinient than using single quotes."
Example: "Why do you use '. "\n";' instead of the PHP_EOL constant?" Most probable answer: "What is PHP_EOL?";
Example: "Why aren't you using namespaces anywhere?" Most probable answer: "What are namespaces?"
Altough this might be a german perspective but I would not hire someone that presents me this kind of code. And for anyone saying "But this is only one book to learn the basics?" why not learn it the right way from the start?