Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [php]

PHP is a widely-used, general-purpose scripting language that is especially suited for web development.

Filter by
Sorted by
Tagged with
0 votes
0 answers
45 views

Add a Custom Billing Field to WooCommerce Checkout, Order Meta, and User Meta

I have implemented a custom WooCommerce checkout field to collect a Tax Exempt Number in the billing section. This field's value is stored in the user meta upon checkout to facilitate future orders. ...
intothevoid0's user avatar
-1 votes
0 answers
60 views

we are facing a time out error ... only have 9 seconds to complete the process [closed]

Given constraints : 1 <= keys[i] <= 2.5 * 10^13 Minimum value will be 1 Maximum value will be 25,000,000,000,000 Sample 1 Given array of n numbers. [100, 15, 30, 10] I need to find the all ...
Muhammad Usman's user avatar
3 votes
1 answer
95 views

Evaluating Extended Operating Hours Past Midnight Across Timezones in PHP

I am working on a project that involves tracking the operating hours of businesses across different timezones. Some of these businesses operate past midnight, and to accommodate this, operating hours ...
tony's user avatar
  • 361
6 votes
3 answers
265 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 ...
CodeWithPhpX's user avatar
4 votes
1 answer
418 views

Get visitor current city via API or display the city the user searched for

I am writing a simple PHP script to display all my available stores in google map. If the user just came in, I need to set the user current city as default city using geolocation (3rd party); ...
Cooperative's user avatar
1 vote
1 answer
78 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 ...
Dimitrios Desyllas's user avatar
3 votes
1 answer
172 views

Sending only modified data from a table to the backend as form data

The frontend has a table with hundreds of rows. Each row consists of different inputs (text, file, ...
pileup's user avatar
  • 421
2 votes
2 answers
206 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 ...
ControlAltDel's user avatar
2 votes
0 answers
130 views

PHP Parser and converter - SOLID and DRY

I am working on a PHP application that transforms data from the input CSV (JSON, TXT, or XML) into an output CSV (JSON or database, for example). The output format differs from the input: some columns ...
friday-json's user avatar
2 votes
1 answer
52 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. ...
cargarm3's user avatar
3 votes
3 answers
664 views

Sanitize URL string for Insertion Upon DB table via Eloquent model

In my case I am saving a URL into my database via Eloquent Model: ...
Dimitrios Desyllas's user avatar
1 vote
0 answers
33 views

PHP WordPress Code - Pricelist Template - refactored

I've been working on a refactoring my old WordPress pricing page template and would appreciate feedback on the code structure, organization, and any potential improvements. The template is used to ...
KermitTheFrog's user avatar
2 votes
2 answers
69 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 ...
JoSSte's user avatar
  • 199
1 vote
2 answers
181 views

PHP WordPress Code - Pricelist Template

I've been working on a WordPress pricing page template and would appreciate feedback on the code structure, organization, and any potential improvements. The template is used to display a pricing list ...
KermitTheFrog's user avatar
7 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. ...
whiteman808's user avatar
1 vote
1 answer
45 views

Rails session after migrate from PHP (improved)

previusly I make a post for Session Logic for User Verification in Rails Migration. Now the improvement version following advice of the comments is here. The problem was the use of `` for executing in ...
ZAMA's user avatar
  • 35
2 votes
1 answer
70 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 ...
ZAMA's user avatar
  • 35
1 vote
0 answers
163 views

Handling large amount of traits and properties in classes

I've got an open-source project that I've been working on for a while, and I'm looking for advice on handling large classes. It's a Laravel 10+ package for building forms, and everything works fine, ...
Second2None's user avatar
4 votes
2 answers
246 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 ...
sammy medawar's user avatar
5 votes
3 answers
1k views

A very simple router for a PHP application

/.htaccess ErrorDocument 404 /inc/index.php ErrorDocument 500 /inc/index.php RewriteEngine ON RewriteRule ^([a-z_-]+)$ index.php?page=$1 [L] /index.php ...
Nathan George's user avatar
2 votes
1 answer
58 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 ...
titac projets's user avatar
4 votes
2 answers
135 views

Apply placeholders to an array in a loop for pdo statements for search functions with unknown numbers of keywords

I'm a newbie to PHP and other programming for that matter. I'm doing this simply to learn. Figured the code could be used to search through a police database or something. The statements are Microsoft ...
Luke Lenacio's user avatar
1 vote
0 answers
101 views

PHP implementing Dependency Injection

I'm trying to implement Dependency Injection in one of my projects. It's a project that when I started I didn't had much experience with sotware development, but now I feel like it's time to do a bit ...
CelsomTrindade's user avatar
3 votes
1 answer
103 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. ...
Tarikul's user avatar
  • 31
4 votes
2 answers
220 views

Querying for vendors and categories

I'm looking for pointers on the best way to optimize my code below. The query is designed to pull for a vendor database in a separate SQL server table that I built a connection to in my wordpress site....
Mike Mann's user avatar
  • 141
4 votes
1 answer
136 views

PHP CSV Parser: Separation of concerns and SOLID principles

I implemented a CSV Parser with Separation of concerns and SOLID principles in mind. Does that code match the principles? Here a sample data (CSV): ...
friday-json's user avatar
1 vote
0 answers
79 views

Force free shipping for WooCommerce Subscription recurring orders only

I'm using WooCommerce Subscriptions and here's what I want to do: Use free shipping for all recurring orders even if the minimum isn’t met. Get rid of any other free shipping choices (like free ...
David's user avatar
  • 11
0 votes
1 answer
275 views

WordPress Plugin for WebP/AVIF Image Conversion

I'm looking for feedback on a WordPress plugin I developed for automatically converting images to WebP and AVIF formats. The goal is to optimize image loading performance. The plugin has the following ...
KermitTheFrog's user avatar
2 votes
2 answers
111 views

Four functions to measure and compare months of duration from one or two dates

I decided to write a few related examples of code, and honestly I don't know if I am overthinking, or just trying to find what is that right way to write functions and how to use them, so that ...
Erasus's user avatar
  • 240
0 votes
1 answer
79 views

PHP login codes suggestions

Now i have a fully functional PHP codes for login and registeration i was wondering if anyone could offer improvements to the code The code: Config.php: ...
Bebo's user avatar
  • 39
1 vote
1 answer
140 views

Follow up to Validation Script in PHP

So I've implemented the suggestions in Original question And now my code looks like this: ...
Bebo's user avatar
  • 39
1 vote
1 answer
117 views

PHP Validation script

The code below is modified slightly from the code in this previous post. I believe the code below could be improved and more secured but i don't know how so someone please show me how an improved ...
Bebo's user avatar
  • 39
5 votes
2 answers
397 views

Parsing gateway ip from `/proc/net/route` in a docker container

In try to replicate the outcome of the following command sequence using php: netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10 I did this using ...
Dimitrios Desyllas's user avatar
0 votes
1 answer
221 views

SQL & PHP login method

My code is working however it seems to be using old outdated php version so less secure and I'm still new to programming so I'd be more than thankful if someone shows me how an improved updated and ...
Bebo's user avatar
  • 39
0 votes
1 answer
133 views

Validating an input in a chatbot

Is this a good approach for validating user input in a chatbot? I am writing an autoposter telegram bot in PHP using the php-telegram-bot library (by Longman). I have a Task class that stores ...
Gigoshkin's user avatar
2 votes
2 answers
243 views

Best Practices for PHP PDO Pagination with Search Functionality

I'm working on implementing a pagination system with search functionality using PHP and PDO. The code I've written seems to work, but I want to ensure that I'm following best practices and avoiding ...
user275476's user avatar
5 votes
3 answers
2k views

Count unique visitor using IP address and make sure that 24 hours has passed before incrementing the counter

I've created a unique page counter using a PHP script. Pages could be videos, images, publications, etc. Every time a new user views a page, I record the entry and increment the view counter. I cannot ...
Marco's user avatar
  • 239
0 votes
1 answer
110 views

Implentation of Data Access Object Pattern

I'm tried to implement the Data Access Object Pattern. I have a base abstract class that is then extended for a specific table. I tried following some guides, but couldn't find a lot of info on this ...
NicholasJohn16's user avatar
0 votes
1 answer
85 views

List of URLs to "convert" to other URLs

I have certain URLs which I want to convert to another, for example, anything that starts with /some/url/: /some/url/a/b/, ...
pileup's user avatar
  • 421
1 vote
2 answers
332 views

How can I make my image upload more secure?

I gathered a lot of information in order to try to make my code as secure as possible, and I would like to know what I can do to improve more its security. (Sorry for my english if it's bad) What did ...
gabriel's user avatar
  • 13
0 votes
2 answers
119 views

Is overloading a database object a bad practice?

I created the below class as a convenient way to create instances of PDO that I then inject into the classes that need access to my database. Instead of doing ...
NicholasJohn16's user avatar
1 vote
1 answer
41 views

Woocommerce send unique pdf

I have developed a code to send tickets (PDF files) of a specific product in the order confirmation. I place the PDFs in a folder (i.e. Tickets) on the server after the purchase is completed. The code ...
user274953's user avatar
0 votes
2 answers
165 views

jQuery + PHP Form Submit and Refresh

Code below successfully processes and submits data to database. Is there anything else that needs to be included / considered? PHP (note-process.php): ...
Matt's user avatar
  • 9
2 votes
1 answer
162 views

Manually inserting or updating a row with timestamps, without Eloquent

I need to insert or update a row that has created_at and last_update timestamps. created_at ...
pileup's user avatar
  • 421
3 votes
1 answer
233 views

PHP MySQLi Wrapper Class For API

I've never had my code reviewed before, so I am taking this opportunity to see what can be improved with my coding style. I am still somewhat "new" to PHP, in the sense that I'm an old dog ...
Bellator's user avatar
  • 131
1 vote
2 answers
229 views

Boolean Value Object

Purpose: I want to accept the value of a checkbox or database field and make a Value Object out of it. The input could be any of y, Y, n, N, Yes, No, yes, no, 1, 0, true, false, or NULL. In the case ...
Tim Morton's user avatar
0 votes
1 answer
96 views

PHP Class to render HTML div styled tables v2 [reviewed by me]

After my previous question I made several changes and came up with this. Remember: I wrote this for PHP 7.0.33. I'm aware I should upgrade, save the advice :) ...
julio's user avatar
  • 199
0 votes
1 answer
176 views

PHP pagination function

After reviewing my previous question I came up with this pagination function. On my first approach I wrote a class thinking about IDE's code assist and the review wasn't positive. In this function I ...
julio's user avatar
  • 199
2 votes
1 answer
489 views

PHP Class to render HTML div styled tables v1

This class aims to render an HTML compliant div styled table. I added a help() method that provides usage and styling in a more user-friendly way. Besides the ...
julio's user avatar
  • 199
2 votes
1 answer
143 views

php tmpdir() alternative to tmpfile()

tmpfile() creates a temporary file which is automatically deleted when php exit. I wanted the same for directories, came up with: ...
hanshenrik's user avatar

1
2 3 4 5
86