Related Content
Recreating Spotify Wrapped In PHP
I quite like the end of the year report from Spotify that they call "Wrapped". This is a little application in which they tell you what your favorite artist was and what sort of genres you listened to the most during the year.
Should A Constructor Throw An Exception?
Let's say you had a class that you wanted to use, but there was some sort of error in creating the object. This might be that the wrong parameters were passed, or the third party service (eg. a database) wasn't available at the time of creation.
PHP Question: Variable Reference
Question
What does the following code print out?
function arrayPrint($array)
{
echo implode(' ', $array);
}
$arrayA = [1, 2, 3];
$arrayB = $arrayA;
$arrayB[1] = 0;
arrayPrint($arrayA);
Creating An Authentication System With PHP and MariaDB
Using frameworks to handle the authentication of your PHP application is perfectly fine to do, and normally encouraged. They abstract away all of the complexity of managing users and sessions that need to work in order to allow your application to function.
Creating Sparklines In PHP
A sparkline is a very small line graph that is intended to convey some simple information, usually in terms of a numeric value over time. They tend to lack axes or other labels and are added to information readouts in order to expand on numbers in order to give them more context.
PHP:CSI - Improving Bad PHP Logging Code
I read The Daily WTF every now and then and one story about bad logging code in PHP stood out to me. The post looked at some PHP code that was created to log a string to a file, but would have progressively slowed down the application every time a log was generated.
Comments
Submitted by Anonymous on Tue, 07/06/2010 - 02:24
PermalinkSubmitted by philipnorton42 on Tue, 07/06/2010 - 08:55
PermalinkHey, really nice script, I can tell you've taken your time on it.
I was dealing with a word dictionary called badwords.txt I found on Google Code which had some words in like 's***'. The played havok with your script until I escaped the charachters:
$text = preg_replace('/\b'.preg_quote($filterWords[$i]).'\b/ie',"str_repeat('*',strlen('$0'))",$text);
I agree, WebPurify is a step too far.
Submitted by Michael Rich on Mon, 12/05/2011 - 03:04
PermalinkThanks for the tip Michael :)
Submitted by philipnorton42 on Mon, 12/05/2011 - 09:09
PermalinkSubmitted by steve17 on Fri, 04/25/2014 - 12:12
PermalinkSubmitted by Jim on Tue, 06/07/2016 - 17:56
PermalinkSubmitted by hashbanganon on Sun, 03/05/2017 - 08:28
PermalinkSubmitted by mike on Thu, 03/15/2018 - 21:07
Permalinkanyone get this to work with preg_replace_callback for php 7?
Submitted by nick on Thu, 04/16/2020 - 20:27
PermalinkAdd new comment