r/PHPhelp • • Sep 27 '23

What is the "modern" way of sanitizing an input in PHP (seriously)?

12 Upvotes

I have user email and password field. I just need a simple code snippet that is uses new PHP syntax/methods. I've been looking for it but different people have different opinion and a lot of them are using a deprecated function. Can someone please provide a link or the code snippet?


r/PHPhelp • • Sep 19 '23

How to get an old PHP 5 website running again (willing to pay)

12 Upvotes

I have a client who has a backup of an old PHP/Flash website. From the timestamps of the files, it looks like it's from around 2009, so I think that it's most-likely using PHP 5.

My client would like to get it running again to show it off in a kind of museum in the office. The computer showing the website does not need to be connected to the internet, so it's OK to use outdated software to get everything working.

The first step would be to get the server / PHP part of the website working again. Then I would worry about finding a browser or emulator or something like that that can run the Flash files.

Does anybody have experience with something like this that could help me out?

I'm on an Apple Silicon Mac so I'm having a hard time getting old PHP versions to run via Docker or Vagrant.

Thanks for your help!


r/PHPhelp • • Feb 07 '23

Solved Need some advice. Which is better? Guzzle or cURL?

12 Upvotes

I'm just learning PHP and I much prefer Guzzle over cURL as it's much simpler and you can achieve the same results with less code. My question is, is there anything about cURL that makes it a better choice? More specifically, for usage with APIs.


r/PHPhelp • • Jun 08 '22

Solved Which PHP framework is good for web applications requiring long term maintainability?

12 Upvotes

Currently I use CakePHP. But are there any framework that is better for long maintained and updated web applications (~10 years). I'm looking for something that doesn't have many breaking changes when upgrading to a new version.


r/PHPhelp • • Jan 05 '22

Question: Why do PHP developers hate sprintf()?

12 Upvotes

I just can't figure it out. My background is in other languages. I get that sprintf() has had some fun issues in C when people don't properly account for length. But in PHP I see code all the time that, instead of using a very clear and concise sprintf(), use concatenations that are impossible to understand easily. Where does this come from? I'm used to something along the lines of:

$s = sprintf("My %s has %d %s and that makes me %s",
    $spouse, $petNumber, $petType, ($goodEmotion ? "happy" : "sad"));

In PHP, I am constantly seeing this:

$s = "My ".$spouse." has $petNumber $petType and that makes me "
    .$goodEmotion ? "happy" : "sad";

I'm honestly curious where this comes from. Is there a history of issues with sprintf() in PHP or is there something else?

edit: updated in markdown to show code


r/PHPhelp • • Oct 03 '20

Taking "The PHP Practitioner" series on Laracasts and...

12 Upvotes

I've been going through the PHP beginner series on Laracasts and I've been having a tough time following along (I was good up until around the "Dynamic Inserts with PDO" lesson). I have experience with JS so I'm not a total beginner, but have never explored backend development before.

My question is... how firm of an understanding should I have of all these new concepts before moving onto learning Laravel? I understand that it takes care of all the small details for you like routing, but I still feel the need to understand everything under the hood. I find myself having to rewatch some videos 3-5x before getting a general grasp of what's going on, and restarted the series completely to get a fresh go at it.

Should I take some time to build projects with the custom MVC framework he builds in this series? Even though he recommends against using it for actual sites? Or should I keep going through the OOP series and then to Laravel before building any big projects for my portfolio?

I have the issue where I feel the need to understand EVERY little detail before moving onto new concepts and I think it's starting to hinder my progress. I've been stuck in tutorial hell for quite a while.

Thanks for the help.


r/PHPhelp • • Aug 21 '20

Recommendations to create graphs and charts from PHP?

12 Upvotes

I'm needing to do some various charts and graphs from mySql/MariaDB data using PHP as the source language.

What do you all recommend as a versatile library to use for creating graphs and charts?

Should I create something using Javascript, a built in PHP library that creates its own images, or something else? I'm more of a PHP programmer than Javascript so I am not super familiar with JS and frameworks, but if I need to I can code PHP to spit out JS or some other tech to create the charts and graphs. What do you recommend?


r/PHPhelp • • Aug 15 '20

Wondering how some of you started learning PHP

12 Upvotes

Hi, if anyone had any spare time, I would love to hear how some of you guys started learning PHP. I'm trying to learn PHP but I am having a hard time trying to get some deep understanding of the language. Im more of the "get the basics down" kind of guy then try doing a basic project so I was wondering if I could get a direction or some ideas.

I checked the PHP subreddit, but it seemed like this was the more appropriate area. If not, then I'd love to hear where I can ask around. Thank you!


r/PHPhelp • • Jun 05 '20

Your favourite tools for PHP web projects

12 Upvotes

Hello,
let's say you are going to make a smaller web project (work for 1-2 weeks) in PHP. What tools/technologies are you going to use no mather what?

It should be:

  1. Framework independend (no Symfony vs Laravel vs CodeIgniter wars please)

  2. IDE independent

  3. Project independent (no mather what web project you do, you use these technologies/tools)

Thanks for your tips :-)


r/PHPhelp • • Jan 01 '19

Dephpugger project - The debugger in terminal to PHP lang

12 Upvotes

Hello guys.

I am coming to advertise this library for debugger in PHP.

One year ago I asked to me if is possible to have a debugger in terminal like IPDB (python) or Byebug (ruby).
I studied the Xdebug lib and made it o/

I called the project as dephpugger

https://github.com/tacnoman/dephpugger

I possible to use with any framework and in the docs have examples to ZF2, Symfony, Lumen, Laravel, etc

Have 120 stars in github.

But nowadays I'm not working with PHP anymore and I'm spending much time to keep it.
I want to know if someone would like to became a contributor to project.

I have some issues opened

https://github.com/tacnoman/dephpugger/issues

Thanks for this

Lumen in example

dephpugger web Image 1.0 - Screenrecord for debug web


r/PHPhelp • • Apr 16 '17

First time writing OOP can anyone check im on the right track.

12 Upvotes

Hello,

So i have written a tool called Statsy it started to gain traction and many people wanted a OOP version that was also available on composer so i started rewriting it i have got the core done and working i just wanted to know if there was any obvious improvements or mistakes i have made as i have never done any OOP before. Heres a link to the OOP version im working on: OOP Statsy Ignore the file structure as that will be changing anyway i have basically wrapped all the classes into the Statsy.php file so thats where all the methods will be used from to make it easier to use (I THINK)


r/PHPhelp • • Jan 22 '17

Can someone explain what this php malware does?

12 Upvotes

So this code was inserted into every single .php file on my webserver:
http://pastebin.com/CMSbWBaD
I've tried running it through unphp and this is what i got:
https://www.unphp.net/decode/a7a9198fc5cf7c7c53480448a36e388f/

Can someone with experience in PHP please explain to me what this malware does?


r/PHPhelp • • Sep 26 '16

Best book/tutorial for writing unit tests

12 Upvotes

I have many years of PHP programming behind my belt, but for some reason I've never got to writing unit tests. When I was starting almost nobody was writing tests in PHP. When tests become industry standard I was senior enough to have junior write them for me. Now I am at the point that I want to finally learn to write them because it's unthinkable that mid/senior dev never wrote a unit test.

Please point me to good (don't have to be free), preferably online resources about how to start with writing tests in PHP.

Recently I am doing project using Codeigniter that I would like to write tests for, so it would be nice if tutorial or book would be framework specific, but don't have to be.


r/PHPhelp • • Sep 09 '16

Solved What does the at sign in @file_get_contents mean?

12 Upvotes
$page = @file_get_contents($url);

r/PHPhelp • • Oct 25 '26

I need advice on upgrading a legacy PHP application.

11 Upvotes

Hi ,

I need advice on upgrading a legacy PHP application.

The application is currently running on:

  • PHP 5.4.7

  • Apache 2.4.3

  • Windows Server

The application is quite old, and I'm trying to determine whether it is feasible to upgrade directly to PHP 8.x or if the effort required to remediate compatibility issues would make a full rewrite a better option.

I am looking for guidance on:

  • How to assess the application's upgrade readiness

  • Common compatibility issues when moving from PHP 5.4 to PHP 8.x

  • Recommended upgrade path (incremental vs. direct migration)

  • Tools or approaches to identify deprecated functions and libraries

  • Criteria for deciding whether to upgrade or rebuild the application

Any advice or experience with similar legacy PHP migrations would be greatly appreciated.

Thanks.


r/PHPhelp • • Mar 23 '26

PHP 7.4 - how "mandatory" is to upgrade to 8.x in this case? Large codebase

11 Upvotes

I manage a large codebase inherited from very old PHP 4 and upgraded constantly during the years up to 7.4.

Now the question is, do I really need to upgrade to 8.X as this is a different paradigm and it is going to be a nightmare. There is an enormous quantity of undeclared variables for example, no types, etc... old fashioned structure. Otherwise the code runs very well in it's current 7.4 version. Object programming is used in a low grade mode but otherwise we'll segmented and working nicely for the task

What would you do? Rewrite, discard and start from scratch, or use as such for a few years to come.

My primary concern is security. This serves public ecom websites and the usage horizon for it is 10 years from now on.

TIA


r/PHPhelp • • Jan 30 '26

How can I get involved in real PHP/Laravel projects to improve my skills?

11 Upvotes

Hi everyone, I’m trying to move beyond tutorials and want to work on real PHP/Laravel code to improve my practical understanding.

I can handle basic to moderate backend tasks and I’m also comfortable deploying and hosting websites.

If anyone here is working on a small project—such as a college project or a basic client website—and needs help with PHP tasks, I’d be happy to contribute and learn.

Any guidance or opportunity would be greatly appreciated.


r/PHPhelp • • Dec 06 '25

Hosting alternatives to hostinger, AWS, and Google cloud I can't use them. So I was looking for a cheap or affordable or free hosting for php website. Also pls if I made a php website without laravel do I need to start again?

11 Upvotes

r/PHPhelp • • Nov 03 '25

What is most often frontend used with Laravel?

11 Upvotes

Hey there! I start learning Laravel, but could not find that much information about the best frontend to stack with. The problem is that some frontend have different behaviour and I'm just losing in that ton of information. Wanna ask: What frontend is usually used with Laravel. For: Fast mvp, Powerful SEO, "Your option".


r/PHPhelp • • Aug 20 '25

Solved Alternative of xampp server

11 Upvotes

I was using xampp for a long time, when i want to change the php version well it is kinda thuff.

I wonder is there any best or good alternative we have?

  • Change multiple php version in one click,

  • Optimized and less buggy,

  • Clean and easy ui.

Please suggest which software i should use.


r/PHPhelp • • Jun 25 '25

Sanitizing user submitted HTML to display

11 Upvotes

Does anyone have any advice on handling user submitted HTML that is intended to be displayed?

I'm working on an application with a minimal wiki section. This includes users submitting small amounts of HTML to be displayed. We allow some basic tags, such as headers, paragraphs, lists, and ideally links. Our input comes from a minimal WYSIWYG editor (tinymce) with some basic client side restriction on input.

I am somewhat new to PHP and have no idea how to handle this. I come from Rails which has a very convenient "sanitize" method for this exact task. Trying to find something similar for PHP all I see is ways to prevent from html from embedding, or stripping certain tags.

Has anyone ran into this problem before, and do you have any recommendations on solutions? Our application is running with very minimal dependencies and no package manager. I'd love to avoid adding anything too large if possible, if only due to the struggle of setting it all up.


r/PHPhelp • • Jul 27 '24

Best way to sanitize user input?

11 Upvotes

Since both strip_tags() and filter_var($SomeString, FILTER_SANITIZE_STRING) are depreciated, what are you all using nowadays to filter/sanitize user string input on form data whether it's going to be used as an email message on a contact form or text saved to a database.

There has to be some reliable ways to continue to check and strip strings of potential html input or other malicious input. What are you all using?


r/PHPhelp • • Jul 08 '24

Is this normal?

11 Upvotes

I'm a beginner in PHP and have been building this project that manages a basketball league (HTML, vanilla CSS, JS, and MySQL).

Is it normal that I don't embed any PHP code in the HTML and just use fetch in API in JS to display requests by the user?

I use basic crud in managing players, teams, and every game's data with basic crud. As a result, I have tons of JS files for each CRUD Operation and a ton more PHP files.

I haven't watched any tutorial that does any of these, I just made it up since I've learned fetch API and spammed it in this project so I have no clue if this is a good approach or not.


r/PHPhelp • • Mar 15 '24

Solved A site to learn PHP with latest and best standard practices.

11 Upvotes

Hello, I am a CS student and this semester I have PHP as a subject. Sadly, the teacher is not good so I need external help. I have recently just completed learning C++ standard 20 from learncpp which is a free site. Thank you Alex for that.
It was very beginner friendly and taught best practices and latest standard of the language while explaining concepts (I know that c++20 is not the latest standard now).
For some reason, I preferred learning from the website instead of watching video tutorials. It was all in text.
Can I get recommendations for something similar that teaches PHP with latest standards and practices that I can use to learn PHP?
Thank you.