TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

PHP 8

472 点作者 pow-tac超过 4 年前

33 条评论

ericbarrett超过 4 年前
Facebook’s backups were written in PHP. Well, the second version was, anyway. (The first version didn’t work so well.) By backups, I mean the central MySQL databases with profile and post information; not media or messages. The “Crown Jewels,” so to speak.<p>It was written by an engineer in a week or so and then handed off to me. I was a storage guy with some programming chops. Fewer chops than I thought.<p>Multiprocess, forking, long-lived, server-side, I&#x2F;O intensive PHP. And it worked brilliantly. Over the following years, it scaled from a backup set of a few hundred TB to many, many petabytes.<p>I extended the code quite a bit, fixed a bunch of bugs (it was version 0 when it launched, no hate to the guy who wrote it), and added statistics for reports and coverage.<p>The main reliability problem ended up being when we switched to HPHP, the predecessor to HipHop. Since the primary and largest customer of this code was the web front-end, changes there would often break our backend code. One I remember was changing fork() to only start a new green thread; saved $millions on the front end, completely broke backups. We ended up getting a special posix_fork() function or something from the HPHP team that restored the old behavior.<p>Eventually I rewrote it in Python 2.7. It took me two complete attempts and then a further six months of tweaking to get it anywhere near as stable as the PHP version, even with brilliant guys like Haiping Zhao constantly re-weaving the carpet under our feet. I never did like it as much as the PHP version.
评论 #25222339 未加载
评论 #25224281 未加载
评论 #25230419 未加载
评论 #25224071 未加载
评论 #25222787 未加载
评论 #25222074 未加载
评论 #25222604 未加载
cstuder超过 4 年前
Apparently some of the deprecations will make this the most backward compatibility breaking version jump of PHP since V4 to V5. (Read a german interview here: <a href="https:&#x2F;&#x2F;www.heise.de&#x2F;news&#x2F;PHP-8-im-Experten-Check-Der-erwartete-harte-Bruch-mit-der-Vergangenheit-4970530.html?wt_mc=rss.red.ho.ho.atom.beitrag.beitrag" rel="nofollow">https:&#x2F;&#x2F;www.heise.de&#x2F;news&#x2F;PHP-8-im-Experten-Check-Der-erwart...</a>)<p>There&#x27;s a long report on Wordpress and PHP 8 and it&#x27;s not pretty: <a href="https:&#x2F;&#x2F;developer.yoast.com&#x2F;blog&#x2F;the-2020-wordpress-and-php-8-compatibility-report&#x2F;" rel="nofollow">https:&#x2F;&#x2F;developer.yoast.com&#x2F;blog&#x2F;the-2020-wordpress-and-php-...</a>
评论 #25221091 未加载
评论 #25221007 未加载
评论 #25222114 未加载
评论 #25220999 未加载
评论 #25223881 未加载
评论 #25221512 未加载
评论 #25222740 未加载
评论 #25224459 未加载
评论 #25225366 未加载
Kim_Bruning超过 4 年前
Finally, after all these years, Named Arguments!<p><a href="https:&#x2F;&#x2F;stitcher.io&#x2F;blog&#x2F;php-8-named-arguments" rel="nofollow">https:&#x2F;&#x2F;stitcher.io&#x2F;blog&#x2F;php-8-named-arguments</a>
评论 #25221490 未加载
评论 #25222047 未加载
评论 #25222514 未加载
评论 #25221593 未加载
dang超过 4 年前
There have been 5 major threads about PHP 8 in the last few months:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24866190" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24866190</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24235440" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24235440</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24320024" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24320024</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24150731" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24150731</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23955197" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23955197</a><p>A couple of those are more technically specific (to JITs and named arguments) but the vast majority are just the usual comments about PHP in general. Nothing wrong with that, of course, except that there gets to be too much of it.<p>This is a harder problem than it seems, because popular projects always get generic discussion (btw if you hate something that&#x27;s still a kind of popularity!) and the alpha and beta releases always get posted and frequently get upvoted for the same (popularity) reason. There&#x27;s a longer explanation about this here if anyone cares: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23071428" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23071428</a>.<p>We downweight generic subthreads when they get stuck at the top of the page, but only sporadically, since it requires manual monitoring. (Btw, emailing hn@ycombinator.com when you notice a generic top subthread in any discussion is always super appreciated! Downweighting those is probably the biggest single thing we can do to improve thread quality.) As for why generic discussion is worse: it&#x27;s repetitive and contains less information. More on that:<p><a href="https:&#x2F;&#x2F;hn.algolia.com&#x2F;?dateRange=all&amp;page=0&amp;prefix=true&amp;sort=byDate&amp;type=comment&amp;query=generic%20discussion%20by:dang" rel="nofollow">https:&#x2F;&#x2F;hn.algolia.com&#x2F;?dateRange=all&amp;page=0&amp;prefix=true&amp;sor...</a><p><a href="https:&#x2F;&#x2F;hn.algolia.com&#x2F;?dateRange=all&amp;page=0&amp;prefix=false&amp;sort=byDate&amp;type=comment&amp;query=curiosity%20repetition%20by:dang" rel="nofollow">https:&#x2F;&#x2F;hn.algolia.com&#x2F;?dateRange=all&amp;page=0&amp;prefix=false&amp;so...</a>
评论 #25221835 未加载
muglug超过 4 年前
See also the splash page: <a href="https:&#x2F;&#x2F;www.php.net&#x2F;releases&#x2F;8.0&#x2F;en.php" rel="nofollow">https:&#x2F;&#x2F;www.php.net&#x2F;releases&#x2F;8.0&#x2F;en.php</a>
yetkin超过 4 年前
Out of curiosity, why match expressions became popular for non functional languages? Without pattern matching on datatypes via cons expression (x::xs matching) it is just another kind of switch or if&#x2F;else. Why do people promote this? here a nice comment on this topic: <a href="https:&#x2F;&#x2F;ocaml.org&#x2F;learn&#x2F;tutorials&#x2F;data_types_and_matching.html#Pattern-matching-on-datatypes" rel="nofollow">https:&#x2F;&#x2F;ocaml.org&#x2F;learn&#x2F;tutorials&#x2F;data_types_and_matching.ht...</a><p>&quot;So one Really Cool Feature of functional languages is the ability to break apart data structures and do pattern matching on the data. This is again not really a &quot;functional&quot; feature - you could imagine some variation of C appearing which would let you do this, but it&#x27;s a Cool Feature nonetheless&quot;
评论 #25221335 未加载
评论 #25221321 未加载
评论 #25224263 未加载
sleavey超过 4 年前
&gt; 0 == &#x27;foobar&#x27; &#x2F;&#x2F; true<p>That&#x27;s PHP7 behaviour that&#x27;s updated in 8 to return false. I&#x27;m not a PHP basher, I really like it these days, but why the heck was that example ever evaluating to true?
评论 #25221030 未加载
评论 #25221177 未加载
评论 #25221062 未加载
评论 #25221020 未加载
评论 #25221015 未加载
评论 #25221058 未加载
acomjean超过 4 年前
I&#x27;m pretty excited. though we&#x27;ve just moved off 5X at work (slow on the uptake..)<p>I like php. It fast enough, easy to learn (we&#x27;ve had new people pick it up).<p>Its my goto for web development, with some of the frameworks, it seems to have a balance of control and automation I like. Really like symfony for its forms and twig templating engine. Symfony makes a lot of things easy, but is flexible enough when you want to change something. (We like writing native db queries with pdo). It has a package manager (only 1 really, which makes that choice easier)<p>I continue to poke around with react and view js but if I end up using one, I&#x27;ll just make synfony my json serving backend.
99_00超过 4 年前
I&#x27;ve never used PHP. Now I&#x27;m learning it with Laravel for my personal project. This is after using C++ with ASP, C# with ASP.NET, Java with Spring and Spring boot at work.<p>The promise of rapid development is the main draw.
dastx超过 4 年前
I find it really weird that the match expression is strict comparison, but everywhere else it&#x27;s loose comparison. Don&#x27;t get me wrong, I prefer strict comparison, and prefer strongly typed languages because of it, I just feel that this is a strange design choice.<p>In addition, the @ operator seems to have functionality changed, and there is plenty of other backwards incompatible changes to go along with it, and yet, one of the main reasons to not choice the @ symbol for annotation&#x2F;attributes was because of backwards incompatibilities. Personally, I find the introduced syntax for attributes terrible, especially when @ is well recognised in the php community thanks to phpdoc annotations.
评论 #25221308 未加载
评论 #25221747 未加载
laszlokorte超过 4 年前
Php was my first language I learned 15 years ago. On that way I really started to hate it because of all it&#x27;s quirks. Many of those have been fixed and nowadays I really enjoy it again and it&#x27;s my goto language for any web project.<p>It really hits a pragmatic sweetspot. It&#x27;s really easy to deploy and frameworks like symfony give you all the power like rails but without the magic.
评论 #25221230 未加载
评论 #25221085 未加载
评论 #25221366 未加载
评论 #25221441 未加载
评论 #25221185 未加载
meowster超过 4 年前
How should one start learning with PHP these days?<p>My experience: hacked together a few PHP scripts over the years to notify me of a website change (5 minute cron job). Before that, I was a very good beginner with VB6 back in highschool.<p>There are a couple of ambitious database-driven website projects I would like to create, but I don&#x27;t know where to start. I like the KISS philosophy, and I think PHP and MySQL would fill that. Is there an obvious alternative that I&#x27;m missing?<p>I was thinking of hoing through the w3schools PHP turtorial. Is there a better or more up-to-date resource?
评论 #25221820 未加载
评论 #25221457 未加载
评论 #25222583 未加载
评论 #25221599 未加载
评论 #25222205 未加载
评论 #25222509 未加载
评论 #25221398 未加载
评论 #25221488 未加载
combatentropy超过 4 年前
I got spoiled by PHP as my first language. It was so easy to get going. I was surprised to learn that other languages didn&#x27;t work the same way, when integrating into a web server. Also it has always been rock solid. A bug in my code brought down only that request for that user, totally did not affect or even slow down responses to other users.<p>People have attacked its syntax forever. I avoided the worst of it by learning PHP around version 4, when it was moving away from magic quotes and register globals --- and I also had the sense to see that those were unwanted anyway. But I think the main reason that PHP hasn&#x27;t bothered me is that I try to use it as little as possible. Let me explain.<p>I consider PHP a glue language, between my database and the user&#x27;s browser. When you use a lot of glue, things get messy. I try to push things out of the middle layer to the edges, if they will fit. So I try to do a lot of data preparation in the database, through fancy queries, so that the data is mostly ready for the HTML template by the time it is received by PHP. It helps that my database is Postgres. For authentication, I try to lean on Apache, so that PHP would just have to consult the CGI variable REMOTE_USER. So PHP acts sort of like an extension language to Apache (even when I&#x27;m using PHP-FPM instead of mod_php). It takes the data from the database and wraps it in HTML. It takes the form submission from the user and hands it to the database (and most server-side data validation is in the database).<p>The people attacking its syntax sound like they are writing an awful lot of PHP per app. And maybe for some things you have to, but not for CRUD apps, I think. I try to keep the middle layer as thin as possible, and I would do that whether it was PHP, Python, or Perl.
评论 #25221574 未加载
评论 #25221861 未加载
评论 #25221611 未加载
评论 #25223149 未加载
wackget超过 4 年前
Where&#x27;s the best place to suggest a new feature or improvement for PHP?<p>I&#x27;ve always wanted to see `foreach` get a built-in iterator&#x2F;counter so you don&#x27;t have to create and use a counter variable manually.<p>Current way:<p>$i=0; foreach ($array as $key =&gt; $value) { echo &quot;Loop $i of &quot; . count($array); $i++; }<p>Possible new way:<p>foreach ($array as $key =&gt; $value, $i) { echo &quot;Loop $i of &quot; . count($array); }
评论 #25222473 未加载
评论 #25222279 未加载
评论 #25222329 未加载
评论 #25224506 未加载
评论 #25225944 未加载
rcarmo超过 4 年前
I can&#x27;t believe nobody has pointed out (yet) that PHP is the quintessential lambda :)<p>That said, it&#x27;s been many (many, many!) years since I moved away from it, but I&#x27;m intrigued by the state of the JIT and the current coding style (last time I checked, around 6.x, it was growing to be verbose and full of backslash-adorned-namespacing).
评论 #25222607 未加载
评论 #25235452 未加载
评论 #25222857 未加载
tasogare超过 4 年前
A lot of the syntax of new features and features themselves are very close or identical to C#, which is a good thing in my book. It’s nice to see the language evolving in a more typed direction while still being super fast to start a project with.
carrja99超过 4 年前
I still love you PHP
评论 #25223692 未加载
electrotype超过 4 年前
I haven&#x27;t touched PHP for a long time now. How is the Unicode support now? I remember having to use some special utilities to handle characters like &quot;œ&quot; properly.
评论 #25222194 未加载
lgeorget超过 4 年前
I wonder what makes the Symfony Demo App not being faster with the JIT compiler (as shown on <a href="https:&#x2F;&#x2F;www.php.net&#x2F;releases&#x2F;8.0&#x2F;en.php" rel="nofollow">https:&#x2F;&#x2F;www.php.net&#x2F;releases&#x2F;8.0&#x2F;en.php</a> and <a href="https:&#x2F;&#x2F;susi.dev&#x2F;php8-benchmark-jit-symfony" rel="nofollow">https:&#x2F;&#x2F;susi.dev&#x2F;php8-benchmark-jit-symfony</a>).<p>Maybe because Symfony already caches things very efficiently&#x2F;cleverly with OPCache?
评论 #25221724 未加载
评论 #25221550 未加载
Thaxll超过 4 年前
Does PHP still has that weird flow where each request is its own process? afair PHP never had an http server baked in, I remember nginx with php etc ...
评论 #25221491 未加载
评论 #25221743 未加载
评论 #25222755 未加载
评论 #25222613 未加载
评论 #25221501 未加载
bnt超过 4 年前
Really looking forward to the match expression syntax!
CraneWorm超过 4 年前
<p><pre><code> 0 == &#x27;foobar&#x27; &#x2F;&#x2F; false </code></pre> &gt; When comparing to a numeric string, PHP 8 uses a number comparison. Otherwise, it converts the number to a string and uses a string comparison.<p>Why do the conversion at all? Why couldn&#x27;t this just be an error? I realise there is also `===` the strict comparison that typechecks arguments, but why not make that the default?
评论 #25221613 未加载
overflow_error超过 4 年前
Though I still wish they officially support async I&#x2F;O, this is an improvement, excited about this!
DJBunnies超过 4 年前
React php is worth checking out. Async stuff like websockets and non blocking redis subscriptions.
评论 #25221432 未加载
评论 #25223935 未加载
评论 #25221272 未加载
mrweasel超过 4 年前
It&#x27;s nice to see the language being cleaned up a bit.<p>PHP was the first language I learned, but the more I used and read code written in other language, the more PHP seemed like a mess, and it got worse the more features are being bolted on.
TekMol超过 4 年前
If I understand it correctly, the next Debian version will come with PHP 7.4:<p><a href="https:&#x2F;&#x2F;packages.debian.org&#x2F;testing&#x2F;php&#x2F;php" rel="nofollow">https:&#x2F;&#x2F;packages.debian.org&#x2F;testing&#x2F;php&#x2F;php</a><p>Is that correct?
flemhans超过 4 年前
Already supported by my local provider, &lt;<a href="https:&#x2F;&#x2F;gigahost.dk&#x2F;en&#x2F;features&#x2F;php" rel="nofollow">https:&#x2F;&#x2F;gigahost.dk&#x2F;en&#x2F;features&#x2F;php</a>&gt;
评论 #25223558 未加载
Sodaware超过 4 年前
I don&#x27;t really like PHP, but it pays my bills. There are some big improvements in this release. Named arguments and actual attributes (instead of special tags in comments) are really nice.
young_unixer超过 4 年前
If there was a language&#x2F;framework with the simple PHP workflow of dropping files into a directory, but with a good syntax, we would probably be colonizing other galaxies at this point.
thiht超过 4 年前
It seems like an amazing release. I&#x27;ve not touched PHP code for at least 5 years but it makes me want to play with it again :)
richardjennings超过 4 年前
PHP is the poster child for the peoples syntax.
pornel超过 4 年前
Dupe <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25219870" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25219870</a>
idoubtit超过 4 年前
I get paid for writing PHP code, and the quality of the official PHP documentation worries me. I&#x27;ve searched for several of the changes introduced by the 8.0 version, and I could not find them. For instance, the page titled &quot;Function arguments&quot; does not mention the existence of named arguments.<p>The last time I wanted to submit a ticket about a documentation bug, I saw that the ticket was already created months ago. I&#x27;m surprised the PHP process can introduces changes without the related documentation update.
评论 #25222083 未加载