Questions tagged [php]
PHP is a widely-used, general-purpose scripting language that is especially suited for web development.
4,268 questions
7
votes
3
answers
643
views
Optimizing real-time ASCII playback in Python when each frame is fetched as a PNG via GET
Why I made it
I wrote this script for one simple purpose: to Rickroll my friends.
How it works
This is the workflow:
It fetches a .png frame from a PHP endpoint on a website I own. The frame number ...
7
votes
4
answers
652
views
CSV handling class
I'm a hobby coder at best. I know enough to make helpful programs to assist me with day to day life and work (mostly with PHP/JS, some C#). I'm wanting to learn more about good coding practices. I ...
2
votes
1
answer
89
views
Return breakdown of component from database into its constituent materials; correctly handle recursive scenarios
I’m working with a MySQL database that models product compositions and raw materials. There are two relevant tables with columns as shown:
product_recipes:
...
3
votes
1
answer
186
views
Rendering data from mutiple models using controller and send to a single view
I have a master page, where I need to render data from multiple models. I have made a prototype of that page to show only the required conditions.
What is the best approach for controller to retrieve ...
3
votes
1
answer
236
views
Image preview and delete for Laravel blog application
I am working on a blogging application in Laravel 8.
I have put together a way to preview and remove the main article image.
In the ArticleController.php controller,...
2
votes
2
answers
183
views
Convert binary string to text base64 [closed]
I have a dictionary with a lot of symbols, each of which is encoded in a huffman binary string.
Example:
Symbol
Huffman Code
you
010
shall
0111
not
00111
pass
00001
...
...
Therefore I encode the ...
4
votes
2
answers
499
views
Improving upon the Security of my Export Remote Database to Local PHP API
I am working on an in-house application, and I am working on how our application communicates with our remote server.
I have a PHP script that acts as an API to call to our MySQL DB and dump its ...
4
votes
1
answer
176
views
Replace node type in Drupal
In Drupal 11 or greater, this code is used to change the node type of a node. How would you improve the code if at all?
...
2
votes
0
answers
56
views
SPA in Symfony UX Turbo
I am currently learning Symfony UX. My focus today was on UX Turbo. I basically wanted to create a very basic Single Page Application.
User can 'login' using a form, submitting the form should render ...
4
votes
3
answers
1k
views
A function to convert numbers from scientific notation to plain decimal
When PHP converts a number to string (for printing it out, for example), sometimes it may convert it to scientific notation out of nowhere (0.000021 for example). Or the number can be already in a ...
3
votes
1
answer
89
views
Rounding a decimal to the nearest (up or down) 50's integer
I need to round a decimal to the nearest 50's (please correct this phrase because I am not sure how it's called in English)
For example:
...
4
votes
4
answers
239
views
Reversing string in PHP
I got this task to evaluate my knowledges in PHP.
I was asked to avoid using functions like strrev() or array_reverse().
...
3
votes
1
answer
209
views
Detect the social network of a given URL
I am making a class in PHP that detects the social network or instant messaging platform of a given URL:
...
3
votes
1
answer
58
views
Open Source Disposable Email Filter PHP Package
I’ve recently developed an open-source PHP package called Disposable Email Filter and would greatly appreciate a thorough code review. The purpose of this package is to filter out disposable email ...
2
votes
1
answer
194
views
Count how many numbers in a range have exactly three divisors
The challenge
Given array a of n numbers, I need to count how many positive numbers less than each aᵢ have exactly 3 divisors.
Constraints
1 <= aᵢ <= 2.5 * 10¹³
In other words,
the minimum ...
6
votes
3
answers
309
views
Simplified VarDumper in PHP
I wrote a simplified VarDumper and wanted to get feedback on areas I can improve on my code. My biggest area of concern is the captureContext method making sure I get the correct file and line ...
2
votes
1
answer
161
views
Telegram YouTube upload video notification Bot
I made a simple script that notifies a Telegram Channel when a new youtube video is uploaded upon a YouTube channel:
index.php
...
3
votes
2
answers
266
views
Is showing an HTML file that the client uploads safe?
I have created two pages (one straight HTML, the other PHP) to show an HTML file in the context of my server. The reason for this is simply to get access to / the styles in the CSS spreadsheets - not ...
2
votes
1
answer
76
views
Justify Text on Image GD PHP
we are trying to justify a long text into a image and we need to justify it. We have solved the problem with this function, but it's too heavy and takes a long time to process the text justification. ...
2
votes
2
answers
116
views
Migrating configuration method
I have a legacy PHP project using a self-styled configuration file (named globals.inc.php) which is generated by build scripts based on a template included in the ...
8
votes
3
answers
1k
views
A simple PHP login form with PDO
I wrote a simple PHP login form for a website. It has an initialization script, as well as a form to allow a user to login, plus a link to log the user out after logging in.
...
3
votes
1
answer
115
views
Session Logic for User Verification in Rails Migration
This is a logic to create sessions on RoR 7.1.2 based on the last version of the website which was in vanilla PHP, with the upgrade I have to deal with the users that were already signed up but not ...
5
votes
2
answers
310
views
A PHP class for the common database operations?
I'm a CS undergrad, so I don't have much experience. But while coding vanilla PHP projects, I found that I was repeating myself a lot with the CRUD operations. So overtime, I developed a single file ...
2
votes
1
answer
109
views
Production-Readiness Advice for Laravel/ PayPal Integration
I am currently working on integrating PayPal with my Laravel application, and it's my first time incorporating PayPal for production use. I have written the following code and would greatly appreciate ...
3
votes
1
answer
124
views
Laravel seeder for email template settings
This is my Laravel seeder for two database tables. I need to make this seeder more efficient and optimized. How can this be achieved? I would appreciate some tips.
...