Questions
Browse questions with relevant PHP tags
2,346 questions
Has recommended answerDoes my code look secure? And How do I prevent people from entering a page?
Wondering here... if it is secure in a technical sense, in which other non-technical sense it is not secure? Words do matter. I do however agree that many of the comments are badly worded, and don't ...
How to toggle bootstrap nav pane from a button
As mentioned, there are a few issues wrong usage document.getElementById('#nav-volunteers') #getElementById must NOT include # Invalid syntax - tabElement.show(); # .show() is not a native DOM method ...
Confused which one to take: js or php for back end (Laravel or Node.js)
Keep in mind the skills you acquire in web development are largely transferable. There's nothing preventing you from say, learning how to build a web app or an api using Laravel and then trying to ...
Laravel localization using session not applying globally (locale changes in session but app()->getLocale() stays unchanged)
This is not a translation file issue. It is a request lifecycle/middleware registration issue. And in Laravel 11/12, middleware registration is typically done in bootstrap/app.php, not app/Http/Kernel....
Recommended tool for sending WordPress form data to REST APIs with Bearer Token auth?
Any HTTP client library like cURL or Guzzle will do this job
Magento stable version
https://magento.stackexchange.com/questions/368385/how-to-upgrade-magento-from-2-4-1-to-2-4-6 has a guide, different version numbers but the same principles ought to apply. What have you researched or ...
turn my html+css+php code into a PDF as an email attachment
Possibly your system is lacking a relevant root certificate or something like that. There may be some existing solutions out there
How do you correctly enforce only one active row per user with Doctrine and PostgreSQL under concurrent requests?
logic and feeling should normally go together, so not only see but first of all feel the logic. you don't solve constraints. you define them, then you use a system that can guarantee them. if you're ...
PHP switch statements for mixing scalars and objects
Why would you ever want to do this anyway? What is the real-world coding scenario that would mean you have a variable where you can't predict whether it'll end up being an integer or an object at ...
Is this JS script vulnerable to XSS?
Your usage of htmlspecialchars() is inappropriate and potentially problematic. htmlspecialchars() is an output filter, only to be used specifically when outputting data into a HTML document. It is ...
How can I safely generate deterministic cache keys for complex PHP arrays (including objects) without risking collisions?
I use json_encode(). In general it seems to be faster, but this isn't always true. It doesn't really matter what you use. Both, for instance, allow you to define custom algorithms. However, serialize()...
PHP arrays or SQL query in loop?
Put them in the same database then, or link the database. Having relational tables in separate databases is a poor design, really, and creates problems like this one that don't need to exist
Displaying information from php arrays in html
It's very unclear where you're stuck. Your title is clear (but you could easily Google that to get existing examples), however your description is then long, rambling and doesn't really get to the ...
Tracking GTM real login/registration form conversion (not button click) - same GA4 ID on prod & preprod, AJAX form, no thank-you page
I would have thought that seeing some code would really help here. Also why is this in the "best practices" category? It sounds more like a technical/troubleshooting question.
Code for website where membership profiles are shown only to those who fit criteria
Well, the page that displays lists of profiles will need an algorithm to determine who is a match and who isn't, by checking against all the criteria. A SQL query against the profile table which has ...
How do I differentiate each device so that each one has its own unique refresh token linked to the same account?
Tokens are often connected to certain device properties, to prevent session hijacking. I cannot judge, from what you wrote, how big a risk this is for your application. Thinking about the actual ...
Get a single data entry from a custom database table in WordPress?
You have no evidence that the variable is a string. But yes it's better to use prepare(), either way.
Issues converting Figma designs to a full WordPress theme using Open AI
Agree with the previous comment - please focus it down to one specific issue that you're facing. That'll make it easier for people to respond, make the discussion more coherent, and make it easier to ...
How does the_excerpt() decide the length of text in a custom WordPress theme?
Seconded. What puzzles me is why people don't just search - it requires a tiny bit more effort but they'd get their answer a lot faster than waiting for us google it for them (or to tell them to ...
Use middleware except if auth user is admin
You can simply add this in your middleware. above if (! $request->user()?->subscribedToPrice // Now Admins can pass without subscription if ($user->roles->pluck('name')->contains('admin'...
How can I fix the "exceeded quota" issue when using AI to generate articles in Laravel?
Well OK but that certainly doesn't mean you're automatically entitled to another company giving you free use of their AI services. It's not really clear why you seemed to think that would be likely.
PHP Variable Naming
Well this can be done with variable variables, but only like this: $tbl_Fld_type = ${"tbl" . $_tbl . "Fld_type"}; $tbl_FormTypes = ${"tbl" . $_tbl . "FormTypes"...
PHP shorthand for isset && truthy
The knowledge sought in this question already exists on this platform: Why check both isset() and !empty() ...15 years ago.
imap_utf8 not always converting utf-8 text
imap_utf8() is not a general RFC-2047 decoder and it only decodes valid RFC-2047 encoded words. Seems your input is not a single encoded word. It's a header-style string RFC-2047 explicitly states: ...
Example .gitlab-ci.yml for Laravel 12 with MariaDB that seeds database before running php artisan test
When you execute the end-to-end test integrating your code with the database migrations and database handling, you need to set-up (provision) the whole test-system first. By default examples the ...
Does PHP Header Location Send HTTP Referrer information?
Am I doing right...well what happens when you try it?
My own OAuth server for authentication on my client application with the ROPC flow
Not sure on what your motivations are to develop your own OAuth2 server capable of an ROPC flow. If you own the server as well as the client application does your OAuth2 server implementation need ...
Changes to the XAMPP httpd main server config file to alter home path for PHP files
Provide ad-hoc configuration and use the production defaults in case of not set: https://www.php.net/get_cfg_var
MySQL Eloquent ORM - where clause: value could be null
You could always do if ($value === null) { $query->whereNull('column'); } else { $query->where('column', $value); } (as Gemini suggests), but then you're doing what the Framework is already ...
How to change the title of the billing field?in Woocommerce
You can do this add_filter( 'gettext', 'change_billing_title', 20, 3 ); function change_billing_title( $translated, $text, $domain ) { if ( $domain === 'woocommerce' ) { if ( $text == '...
Why does Laravel read the schema as if it had 2 primary keys? [duplicate]
The error is in $table->integer('class_level', 3); Syntax integer($column, $autoIncrement = false, $unsigned = false) You can use unsignedTinyInteger() integer() FYK. (In future, hels you debug) ...
Deploy Laravel version 12 (PHP, Inertia, ReactJS, Tailwind) to cPanel shared with no SSH Access
Sorry you'll have to bear with me as I'm not a Laravel expert, but are you absolutely sure you need to run those in the live environment - you can't just deploy ready-made files and database and run ...
`docker-php-ext-install opcache` works with PHP 8.4 but not PHP 8.5 [closed]
As documented in the PHP 8.5 changelog, since PHP 8.5 the Opcache extension now always ships with PHP (non-optional). So you don't need to install it any longer. Opcache: Make OPcache non-optional (...
Problem with module during dolibarr update [closed]
You have upgraded to the wrong version. The 20.0.2 release is an update for the 20.0 branch. But you are coming from the 16.0.3 version, so the 16.0 branch. Please follow the upgrade instructions for ...
Symfony/Doctrine: PostgreSQL Migration Issue – Undefined column error only in HTTP Kernel (CLI works)
What you call out as a // Temporary Fix #[ORM\Table(name: '`user`')] actually is making use of the correct form to tell the Object Relational Mapper (ORM) what the actual name is. As user is a ...
How does a recursive function work in PHP?
hasn't $i been incremented 3 times by that point ...yes, but it gets incremented within the scope of each individual call to the function - and then thrown away, because (aside from the echo rec($obj)...
Symfony monolog add additional info to all logs
Problem is that some logs (e.g. deprecations) are logged before Kernel::request event. That means there is no "current request" in strack. Sure, but as that will ever be you need something ...
Splitting SQL output evenly into 3 HTML columns
Some sample data and expected result would go a long way to making your question clearer. And yeah this would have been better posted on the main troubleshooting posts rather than advice, I think. ...
malformed uuid format sql server on mac
First of all it is very essential to know that you actually have the uniqueidentifier 16-byte column type and that the Relational Data Base Management System (RDBMS) is Microsoft SQL Server. Let's ...
(WordPress) Execute SQL query in a specific product purchase
Presumably there is some part of the code which handles purchases. Maybe it even has events or hooks you can subscribe to. Either way, find that bit of code and add a function there to run your SQL ...
Laravel Service Container: Am I doing the right thing?
At this point, I'm not even sure if I'm doing the right thing, or am I even overcomplicating things? That depends. In your original design, both the array of class constants and their app-factory ...
WordPress + Rootless Docker File/Directory Permission Issue
In particular, is there a recommended pattern for WordPress + rootless Docker (named volumes vs bind mounts, which user should own /var/www/html, etc.) that avoids these “Destination directory not ...
Session ini settings cannot be changed after headers have already been sent in wp-config.php
Just the PHP 101 here explained by the error message in context: PHP Fatal Error: ini_set(): Session ini settings cannot be changed after headers have already been sent in /home/moonlighok/www/wp-...
Filament PHP: Memory exhausted when selecting all table records (500k+ rows) - How to limit or optimize?
For your warning needs there is the ->count() method For your limit needs there is the ->take() method Exemplary Pseudo Code: $limitInclusive = 150_000; ... ->action(...
Which language you should learn for Hybrid or Web view app?
Which language you should learn for Hybrid or Web view app? One that works for you and you are comfortable to program with. Which language is simple like procedural code for Hybrid or Web view app? ...
WooCommerce voucher PDF sometimes not sent after payment — Dompdf process silently fails after render
Your Apache logs show a couple of "well known" Apache FastCGI error codes (AH10157 / AH10149) that are typical for crashing PHP scripts, common when WordPress consumes too much memory or ...
Text file with JSON data became corrupted
You can't have your cake and eat it The file is read and written at different times, if not several times simultaneously. That the file is written in that way (per your code), is the only reason that ...
PHP 8.4 rounding gives different result than 8.2
This was a long standing regression introduced with PHP 5.2.7. PHP 4 and 5 versions prior to it rounded to 255. PHP version 8.4 has finally fixed the round() return value float. Better late than never ...
How do you use set() on PHP arrays?
When using setters/getters on arrays, does your set() override the entire array or just the key? What is the accepted or best practice for this? If you're looking for arrays with add or set, there is ...
Connecting to Excel from PHP using PDO
In ODBC the first row is treated as column headers or data depends on the HDR setting. HDR=NO, which is correct. in newer versions of the Excel ODBC driver may still infer headers based on the data ...
Simply submit a proposal, get it approved, and publish it.
See how the process works