Skip to main content

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
2 votes
1 answer
44 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: ...
pileup's user avatar
  • 441
2 votes
2 answers
43 views

Sending Firebase Cloud Messaging Notifications via FCM HTTP v1 API with PHP

This is my first time using FCM, and I had a lot of trouble finding up to date examples on how to send notifications using Firebase Cloud Messaging Notifications via FCM HTTP v1 API with PHP. I'd ...
tony's user avatar
  • 383
4 votes
3 answers
90 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(). ...
user avatar
1 vote
0 answers
42 views

Testing PHP CodeIgniter 3 controller with PHPUnit

I want to unit test my PHP website, which uses the outdated framework CodeIgniter 3. CodeIgniter 3 uses the MVC pattern, and each page on the website corresponds to a public method in a controller. I ...
RedDragonWebDesign's user avatar
0 votes
0 answers
30 views

injecting the laravel debugbar into a VueJS app served via vue-cli-service

My team develops an app with an API using the Laravel framework and the front-end is developed with VueJS. Locally vue-cli-service serve (a wrapper around Webpack) ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
3 votes
1 answer
175 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: ...
Dimitrios Desyllas's user avatar
1 vote
0 answers
82 views

comment-monk - Comment hosting script for static blogs and websites

So few days ago, I had created another review request for sqlite database schema for a comment hosting system. Now that the app development is complete, I have pushed the initial version on github. As ...
Prahlad Yeri's user avatar
2 votes
1 answer
36 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 ...
sint's user avatar
  • 21
1 vote
0 answers
82 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
2 votes
1 answer
134 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 ...
Muhammad Usman's user avatar
3 votes
1 answer
108 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
  • 383
6 votes
3 answers
272 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
428 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
92 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
182 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
  • 441
2 votes
2 answers
210 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
149 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
56 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. ...
Picture with words's user avatar
3 votes
3 answers
696 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
37 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
71 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
195 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
48 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
75 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
171 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
250 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
62 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
140 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
104 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
221 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
138 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
80 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
281 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
113 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
142 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
118 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
407 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
224 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
252 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
86 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
  • 441
1 vote
2 answers
338 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
120 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

1
2 3 4 5
86