PHP

64bithero, in Why PHP continues to be a popular but divisive programming language
@64bithero@mstdn.games avatar

@symfonystation I love using the language and I’m tired of people claiming it’s obsolete and not useful. Not everything needs to be c-sharp or rust

slazer2au, in Why PHP Usage Has Declined by 40% in Just Over 2 Years

I did not expect WordPress to be the reason PHP is declining but hot dam that graph drop is horrific.

https://cdn.thenewstack.io/media/2024/04/e3e39ac0-builtwith_php24-1024x890.png

grandel, in 10 tools that every PHP developer should use

The only “must have” I agree on is Xdebug and an IDE (but not specifically PHPStorm)

grandel, in 10 tools that every PHP developer should use
  1. Spotify

Wat

lianass, in PHP 8.2: A Glimpse into the Future of Web Development

If you, like me, are creating a website. I would advise you to pay attention to the website database. This is a very important indicator and the key to success. Databases are very important now and turn a website into a dynamic platform.

cxj, in Failwind UI And The SPA Clown Shoes (HTML Illiteracy Part 4)
@cxj@phpc.social avatar

@symfonystation Wish I could read this but don’t want an app or a FAANG snooping on me, so oh well.

tito_swineflu, in Reducing PHP's CPU usage by nearly 40% by upgrading from Ubuntu 20.04 to 22.04
@tito_swineflu@sfba.social avatar

@symfonystation This seems like a shocking indictment of Ubuntu 20.04 to me. Is there any analysis of the underlying reason? I couldn't find any in this article.

symfonystation, (edited )
symfonystation avatar

@tito_swineflu Not that I know off. You might try contacting the author for the details of their setup.

sirber, in Reducing PHP's CPU usage by nearly 40% by upgrading from Ubuntu 20.04 to 22.04
@sirber@fosstodon.org avatar

@symfonystation PHP version upgraded too?

dcoderlt,
@dcoderlt@ohai.social avatar

@sirber @symfonystation
The first graph shows they were running php 8.2 on both OSes.

oliver, in Never write another loop again
@oliver@phpc.social avatar

@symfonystation I don't get it, are loops now evil? Why would one want to not use them? Stuffing arrays into collections in order to manipulate them "nicely" is not a crime, sure. I just have a problem understanding why the other way is presented as bad/no-no.

godlike, in DepScan ❤️ PHP
@godlike@phpc.social avatar

@symfonystation The real issue here is that too many PHP applications are not configured to work with a single PHP entrypoint, instead, they enable any dot php file to be served. This is criminal often, specially on nginx where you can't ship these rules like Apache (an .htaccess file on web root) and users share their own rules without realizing the hazardous conditions.

abhibeckert, in What’s new in PHP 8.4

Seems like a pretty modest release, other than the new JIT.

ernest, in Code quality tool PHP_CodeSniffer has a new maintainer but needs corporate support
ernest avatar
Danakin, in PHP 8.3 Released

Pretty happy with a smaller incremental release. The only feature I see myself using immediately will probably be typed constants, but I like the datetime exceptions and json_validate as well.

grandel, in Why use declare(strict_types=1) in PHP - Fast tips

Is this still necessary with php 8+? With all the type hinting and so on?

abhibeckert, (edited )

Is it necessary? No. It never was. But it is recommended.

Consider this code:


<span style="color:#323232;">function add(int $a, int $b) { return $a + $b; }
</span><span style="color:#323232;">
</span><span style="color:#323232;">$result = add(5, '10');
</span>

In strict_types mode, passing a string will throw an exception. In the default mode (including in PHP 8), the string will be silently cast to an integer.

Here’s a more realistic example:


<span style="color:#323232;">$result = add($_POST['a'], $_POST['b']);
</span>

HTTP values are always strings. So that code will only work with strict types disabled… and there is a lot of PHP code in the world that relies on this arguably “bad” behaviour.

I’d bet one day strict types be enabled by default. So if you want your code to be future proof… get used to enabling it now for all new files. Also I agree with @Dwoncount - you should really be using JSON instead of $_POST. And your JSON should have integer values, not strings.

Downcount, in Why use declare(strict_types=1) in PHP - Fast tips

Furthermore working with HTTP requests can be frustrating with strict typing enabled, since in HTTP requests everything is a string.

Sending the payload as JSON and you can be (quite) strict again.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • php
  • DreamBathrooms
  • magazineikmin
  • mdbf
  • everett
  • Youngstown
  • slotface
  • Durango
  • khanakhh
  • thenastyranch
  • rosin
  • kavyap
  • InstantRegret
  • GTA5RPClips
  • Backrooms
  • JUstTest
  • hgfsjryuu7
  • tacticalgear
  • cubers
  • osvaldo12
  • cisconetworking
  • tester
  • normalnudes
  • ethstaker
  • modclub
  • Leos
  • anitta
  • provamag3
  • lostlight
  • All magazines