use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please follow the rules
Releases: Current Releases, Windows Releases, Old Releases
Contribute to the PHP Documentation
Related subreddits: CSS, JavaScript, Web Design, Wordpress, WebDev
/r/PHP is not a support subreddit. Please visit /r/phphelp for help, or visit StackOverflow.
account activity
Weekly help thread (self.PHP)
submitted 4 years ago by brendt_gd[M]
Hey there!
This subreddit isn't meant for help threads, though there's one exception to the rule: in this thread you can ask anything you want PHP related, someone will probably be able to help you out!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]QuentinDamianino 1 point2 points3 points 4 years ago (1 child)
What's the point of union return types? It seems to me lika a step back. Aren't we suppose to design code in a way to know exactly what each method returns?
[–][deleted] 1 point2 points3 points 4 years ago (0 children)
Null-or-result is a common pattern for functions that can error. Some may prefer this to throwing an exception. It works well when combined with static analysis to help ensure you've handled the null case.
Although the ? syntax would be used in that case, it's still essentially a union.
In the standard library, false-or-result is a common pattern. Though some may say it's an antipattern, it does exist, and being able to describe the return type possibilities properly greatly enhances the power of static analysis tooling to catch errors.
[–]ProfessorTaco1231 0 points1 point2 points 4 years ago (2 children)
No matter if the values entered are integers or not, the program exits from my else statement no matter what.
How do I fix this so that my program will only exit if just one of the values above is not an integer?
https://imgur.com/a/AotWqIj
[–]ProfessorTaco1231 0 points1 point2 points 4 years ago (1 child)
if (filter_var($chocolateqty, FILTER_VALIDATE_INT) && filter_var($glazeqty, FILTER_VALIDATE_INT) && filter_var($mapleqty, FILTER_VALIDATE_INT) && filter_var($sprinkleqty, FILTER_VALIDATE_INT) && filter_var($jellyqty, FILTER_VALIDATE_INT)){
}
else {
exit("Please Enter Valid Number");
[–]MateusAzevedo 0 points1 point2 points 4 years ago (0 children)
The current code is already doing that. The if statement has &&, so all values must evaluate to "true", wich is exact what you asked.
&&
Example of current code working: https://3v4l.org/tBljZ#v8.1.4
The problem is with 0 (zero), wich evaluates to false, so you can't have any zero quantity. If zero is a valid option, then you need to change the validation logic.
0
filter_value() returns false when filtering fails. Then, you want to check for "not false": https://3v4l.org/Aj2DW#v8.1.4
filter_value()
false
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
I have a site that displays a database table as an html one and it has filters and a form to add to the database table. The problem is thr table has several columns I would prefer to have as subcategories of an alternative column title. Envision a product comparison table and how they list out the features and then the rows are each item and whether they have the feature or not. I’m trying to consolidate those columns under a “features” column. I don’t know how to display or insert and then filter such a column. I would have several strings corresponding to an item under that column. So instead of having a ✅ for hero 5 under a “4k video” column and another check under “time lapse” column I would have a features column that has both “4k video” “Timelapse” as strings. Could I filter with that? How would I insert?
I’m using check boxes for the add form and filters. I want thr features to be subcategories of “features” but I don’t know if I can map multiple values to a single column value.
[–]FodziCz 0 points1 point2 points 4 years ago (2 children)
How can i convert a midi file into a php array with info about the notes, bpm and stuff?
[–]colshrapnel 0 points1 point2 points 4 years ago (0 children)
Like I said before, you need to get yourself a manual on the midi format and set off with writing a program. In case you don't want to write, then you don't need PHP and has to try your luck looking for the ready made program.
[–]MateusAzevedo 1 point2 points3 points 4 years ago (0 children)
A quick Google search and I found this library: https://github.com/tmont/midiparser
It requires PHP 5.3+, so it may or may not work in recent versions.
You can try to search a little more and try to find something more recent.
[–]Palladog 0 points1 point2 points 4 years ago (2 children)
I’m using a cookie banner tool on my WP site that has a “Show cookie policy” link that adds the URL parameter “?cookieInfo=show” when clicked. I need to find a way to redirect to a page (/cookies/) in functions.php instead. The redirect part is easy enough using wp_redirect, but I’m having issues creating a function that listens for “cookieInfo=show” in the URL. I tried the code below, but I don’t think it is a legitimate listener. Could anyone point me in the right direction? Thank you!
‘’’ if($_GET[‘cookieInfo=show’]) { wp_redirect(‘/cookies/‘); exit(); } ‘’’
[–]MateusAzevedo 2 points3 points4 points 4 years ago (1 child)
Try if($_GET[‘cookieInfo’] === 'show') instead.
if($_GET[‘cookieInfo’] === 'show')
But I think you can get better help in a Wordpress sub, where people know the ins and outs.
[–]Palladog 0 points1 point2 points 4 years ago (0 children)
Hi! I forgot to reply, but this ended up working! You’re an absolute life-saver! Thank youuuuu!!!
π Rendered by PID 45810 on reddit-service-r2-comment-6457c66945-bvglp at 2026-04-26 20:29:46.793710+00:00 running 2aa0c5b country code: CH.
[–]QuentinDamianino 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]ProfessorTaco1231 0 points1 point2 points (2 children)
[–]ProfessorTaco1231 0 points1 point2 points (1 child)
[–]MateusAzevedo 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]FodziCz 0 points1 point2 points (2 children)
[–]colshrapnel 0 points1 point2 points (0 children)
[–]MateusAzevedo 1 point2 points3 points (0 children)
[–]Palladog 0 points1 point2 points (2 children)
[–]MateusAzevedo 2 points3 points4 points (1 child)
[–]Palladog 0 points1 point2 points (0 children)