🐘 PHP Digest

100 result(s) for “function”

1
NVlabs/cutile-rs

cuTile Rust provides a safe, tile-based kernel programming DSL for the Rust programming language. It features a safe host-side API for passing tensors to asynchronously executed kernel functions.

Trendshift ▲ 76 NVlabs 1mo ago ⚠ Safety
2
voku/portable-ascii

🔡 Portable ASCII library - performance optimized (ascii) string functions for PHP.

GitHub ▲ 575 voku 1mo ago ⚠ Safety
3
ES6 let VS const variables

In the last post we learned all about how scoping works with JavaScript let, const and var variables. We now know that var is function scope, and now we know that let and const are block scope, which means any time you’ve got a set of curly brackets you have block scope. N…

Blogs wesbos.com 💬 49 wesbos 120mo ago
4
React’s New Context API Explained

Hey Folks! React 16.3 has a new Context API which makes accessing data and functions anywhere in your application a snap. If you ever find yourself passing data down via props 4-5 levels deep, context might be what you are looking for. Enjoy! Code Examples available at https://g…

Blogs wesbos.com 💬 32 wesbos 102mo ago
5
Tagged Template Literals

One feature that comes along with template literals, or template strings, is the ability to tag them. That means is that we can run a template string through a function, and rather than have the browser immediately assign that value to a variable, we can have control over how th…

Blogs wesbos.com 💬 21 wesbos 118mo ago
6
JavaScript Arrow Functions Introduction

ES6 has introduced arrow functions which have three main benefits. First, they have a concise syntax. Secondly, they have implicit returns, which allows us to write these nifty one-liners. Thirdly, they don’t rebind the value of this when you use a arrow function inside of…

Blogs wesbos.com 💬 15 wesbos 120mo ago
7
When Not to use an Arrow Function

Before you start going absolutely bananas on using arrow functions everywhere, we need to chat. Arrow functions don’t replace regular functions. Just like Flexbox and floats, pixels and rems and anything else new that comes along, the older thing still retains lots of util…

Blogs wesbos.com 💬 10 wesbos 120mo ago
8
MySQL 5.7: SQL functions for JSON

For decades MySQL has considered BLOB a sink for data junk that didn’t fit the strictly typed SQL bill. As the outside world began voting for JavaScript, JSON and key-value/key-document stores, TEXT/BLOB was rediscovered as the only way to store JSON inside MySQL. But havi…

Blogs blog.ulf-wendel.de 💬 7 admin 156mo ago
9
JavaScript Default Function Arguments

Default function arguments in JavaScript are here. This is one of those features that’s going to make your life much easier, and make your code much more readable and maintainable. Let’s say we have a function called calculateBill which is going to take in three thin…

Blogs wesbos.com 💬 4 wesbos 120mo ago
10
Serializing Data Like a PHP Session

PHP has several built-in ways of serializing/unserializing data. The most cross-platform is json_encode; pretty much every programming stack can JSON decode data that has been encoded by any other stack. There's also PHP's native serialize function, which is not as cross-platfor…

Blogs blog.everymansoftware.com 💬 6 Josh Adell 161mo ago
11
Similarity-based Recommendation Engines

I am currently participating in the Neo4j-Heroku Challenge. My entry is a -- as yet, unfinished -- beer rating and recommendation service called FrostyMug. All the major functionality is complete, except for the actual recommendations, which I am currently working on. I wanted t…

Blogs blog.everymansoftware.com 💬 4 Josh Adell 175mo ago
12
JavaScript Arrow Functions and this scoping

We’ve learned about the concise syntax of arrow functions. We’ve learned about the implicit return of arrow functions. The last thing we’re going to learn about and probably the most important is that the fact that this keyword does not get rebound. What does t…

Blogs wesbos.com 💬 2 wesbos 120mo ago
13
PHPConsistent : a new tool to verify your calls and documentation quality

Back in 2009 and 2010 I wrote about a PHPUnit patch I wrote to automatically verify parameter types in function calls. The feature never made it into PHPUnit and honestly it didn’t really fit into the feature set either. Although I still plan on releasing it as a PHPUnit e…

Blogs techblog.wimgodden.be 💬 2 wimg 146mo ago
14
Building an Array with array_reduce?

Whether it’s twisting a function or taking advantage of side effects and flexible language constructs, it’s no secret I occasionally take joy in writing bastard PHP code. The other day I was in an evil mood and used array_reduce() to construct an array. If you’re not familiar wi…

Blogs zaemis.blogspot.com 💬 1 Timothy Boronczyk 159mo ago
15
Склонение слов в PHP после цифр

Довольно частой задачей на PHP является склонение слов, которые идут после какого-либо числа, например, 1 день, 2 дня, 5 дней или 1 раз, 2 раза, 5 раз или 1 год, 2 года, 5 лет. Данную задачу решить довольно легко, используя специальную функция и массив слов. function plural_type…

Blogs eddifisher.wordpress.com 💬 1 eddifisher 168mo ago
18
Get the first weekday of the month in PHP

A simple method to return the first weekdsay of a given month and year getFirstWeekdayInMonth private function _getFirstWeekdayInMonth($month, $year, $day = 1) { $dateData = getdate(mktime(null, null, null, $month, $day, $year)); if (in_array($dateData['wday'], range(1, 5))) { r…

Blogs lenss.nl Thijs Lensselink 154mo ago
19
Workaround Ubuntu 12.04 mysterious system freezes

I have two machines running Ubuntu 12.04. One of them is very stable. And hardly ever gets rebooted. The other machine is displaying some odd behavior every now and then. And with odd behavior i mean. It just completely freezing up. The only thing functioning at that moment is t…

Blogs lenss.nl Thijs Lensselink 168mo ago
20
PHP Internals News: Episode 89: Partial Function Applications

PHP Internals News: Episode 89: Partial Function Applications Thursday, June 17th 2021, 09:17 BST London, UK In this episode of "PHP Internals News" I chat with Larry Garfield (Twitter) and Joe Watkins (Twitter, GitHub, Blog about the "Partial Function Applications" RFC. The RSS…

Blogs phpinternals.news Derick Rethans 62mo ago
21
PHP Internals News: Episode 77: fsync: Buffers All The Way Down

PHP Internals News: Episode 77: fsync: Buffers All The Way Down Thursday, February 25th 2021, 09:05 GMT London, UK In this episode of "PHP Internals News" I chat with David Gebler (GitHub) about his suggestion to add the fsync() function to PHP, as well as file and output buffer…

Blogs phpinternals.news Derick Rethans 66mo ago
22
PHP Internals News: Episode 69: Short Functions

PHP Internals News: Episode 69: Short Functions Thursday, November 5th 2020, 09:32 GMT London, UK In this episode of "PHP Internals News" I talk with Larry Garfield (Twitter, Website, GitHub) about a new RFC that's he proposing related to Short Functions. The RSS feed for this p…

Blogs phpinternals.news Derick Rethans 69mo ago
23
Do Websites Need to Function Exactly the Same on Every Platform?

~ Early 2000s’ Pixel Perfection If you, like me, were building websites back in the early 2000s, you’ll undoubtedly remember the absolute headache that was cross-browser compatibility. What didn’t help back then in this era of Internet Explorer, Netscape, and Firefox was the stu…

Blogs bram.us Bramus! 1mo ago
26
Consistent hashing algorithm

  This is a guest article by NK. You can view the original article Consistent hashing explained on systemdesign.one website. How does consistent hashing work? At a high level, consistent hashing performs the following operations: The output of the hash function is plac…

Blogs highscalability.com NK 41mo ago
27
Notes from switching to vim.pack

I am a long term tmux + neovim enthusiast, and for the last 10 or so years, I’ve been using vim-plug to manage my vim dependencies. I recently learned that very similar functionality was added to neovim core. The vim.pack interface provides a built-in package manager for vim plu…

Blogs mark-story.com 2mo ago
28
Don't abuse the closures

by Pream Totaram I started to read about clean coding practices and started to wonder how they can apply to JavaScript where it is common to define a function within a function. What I started to think is, how could it be possible for a block of code to obey the Single Responsib…

Blogs dev.imagineeasy.com easybibpream 144mo ago
29
Notifications from an event log

User notifications are a feature that came as an afterthought, but turned out to be rather easy to implement - without touching (read: breaking) existing functionality - thanks to having an immutable event log. In the domain I’m working in at the moment, we will often give…

Blogs jefclaes.be 125mo ago
30
Functional one-liner for running totals in C#

Visualizing some data earlier this week I had to compute the running total of a sequence of numbers. For example, if the input sequence was [ 100; 50; 25 ] the result of the computation would be a new sequence of [ 100; 150; 175 ]. Muscle memory made me take a procedural approac…

Blogs jefclaes.be 126mo ago
31
Finding unused code (F#)

Coming from C#, I’m used to the compiler warning me about unused variables. Relying on the compiler to help me with checked exceptions in F#, I noticed that unused values (and functions) would go unnoticed. Having accidentally read earlier that Haskell has a compiler flag …

Blogs jefclaes.be 137mo ago
32
Spinning the wheel: manipulating the odds

The previous post defined a basic set of data structures and functions to spin a wheel of fortune in F#. There was very little mystery to that implementation though. The physical wheel had four pockets and spinning the wheel would land you a win one out of four spins. As a casin…

Blogs jefclaes.be 141mo ago
33
Spinning the wheel

In this post, I’ll define a basic set of data structures and functions to spin a wheel of fortune. In the next post, I’ll show you the simple model casinos use to build a bigger, more attractive pot, without touching the physical wheel and without losing money. Final…

Blogs jefclaes.be 141mo ago
34
Interview with Michael Lochemem

@agiroLoki Show Notes php_trie extension Trie article Functional Programming in PHP Audio This episode is sponsored by RingCentral Developers The post Interview with Michael Lochemem appeared first on Voices of the ElePHPant.

Blogs voicesoftheelephpant.com cal@voicesoftheelephpant.com (Cal Evans) 70mo ago
35
Interview with Larry Garfield

@crell Show Notes Thinking Functionally in PHP PHP RFC: Pipe Operator v2 PHP RFC: Partial Function Application PHP RFC: PHP Namespace Policy Audio This episode is sponsored by RingCentral Developers The post Interview with Larry Garfield appeared first on Voices of the ElePHPant.

Blogs voicesoftheelephpant.com cal@voicesoftheelephpant.com (Cal Evans) 72mo ago
38
Mockery: Mock Return Value Provider Function With Multiple Values

If you've ever written a test in golang, chances are you've used the testify package to make writing tests a breeze. An immensely useful extension of that is the mockery package, which gives you the ability to autogenerate testify mocks for interfaces with ease.

Blogs archybold.com 95mo ago
40
New Python Jupyter Notebooks for python-oracledb

The Jupyter notebooks for python-oracledb have been updated with the latest and greatest functionality to teach you how to use Python to connect to Oracle Database.The notebooks are at github.com/oracle/python-oracledb/tree/main/samples/notebooksPython-oracledb ResourcesPython-o…

Blogs cjones-oracle.medium.com Christopher Jones 9mo ago
41
More Arrow Function Examples

Let’s look at a couple more JavaScript arrow function examples. This is something that comes up often where I’m building an application, and I don’t necessary have the data in the right format that I need. I’m building a website for a bunch of racers, whe…

Blogs wesbos.com wesbos 120mo ago
42
I’m crying. Literally crying. Actual tears in my eyes....

I’m crying. Literally crying. Actual tears in my eyes. Salty. They sting. PHP is physically hurting me. All of these freaking ridiculous function names we’ve been stuck with for twenty years are because of a POORLY CHOSEN HASH FUNCTION ON A DATASET OF ONE HUNDRED SHORT STRINGS. …

Blogs phpmanualmasterpieces.tumblr.com 153mo ago
43
Unsettling

isset — Determine if a variable is set and is not NULL We’re not even through the first sentence of this manual page and I am already wondering why we’re conflating two completely different definitions of a variable being “set” in one function. This funct…

Blogs phpmanualmasterpieces.tumblr.com 160mo ago
44
Getting Started with Search API in Drupal

Implementing powerful search functionality in Drupal requires more than the default search module. Search API provides flexible search capabilities with support for multiple backends, faceted filtering, and advanced content indexing. In the video above, you'll learn how to insta…

Blogs webwash.net Ivan Zugec 7mo ago
47
Mocking Browsershot for faster tests

Spatie's Browsershot is a wonderful package that uses puppeteer to render a web page to transform it into an image or PDF. Having this functionality covered by tests generally requires you to install puppeteer in your CI environment and can slow down your tests a lot.

Blogs rias.be Rias Van der Veken 53mo ago
48
Combining two numbers into a unique one: pairing functions

Over the past couple of years I’ve grown my interest in image and data compression — it’s a very interesting field, with a lot of interesting solutions to important and lucrative problems (think Dropbox). Over the past few days I was running some experiments an…

Blogs odino.org Alessandro Nadalin 68mo ago
50
Laravel 13 with TEAMS in Starter Kits: Project Demo

Laravel 13 starter kits have a new feature of Teams! In this 14-minute video, I will show exactly how it works, and how to create functionality with Eloquent models scoped by team.

Blogs laraveldaily.com Povilas Korop 3mo ago
52
Docker PHP/PHP-FPM Configuration via Environment Variables

ed: If you want to run the containers right now, jump ahead to How to Use the Images. For several months now I have been working on PuPHPet.com’s replacement. It is a Docker-based GUI functionally similar to PuPHPet. Docker, like Vagrant, allows sharing directories and files fro…

Blogs jtreminio.com 93mo ago
53
III. Chainable Middleware

It turns out that Handlers provide a nice way to create a chain of HTTP middleware. There's more than one way to go about this, but they all use http.Handler. If you google it, you'll come across examples that have you nest function calls in a way that gets grim pretty quicly. f…

Blogs fideloper.com 46mo ago
54
Laravel/Symfony Console Commands & Stderr

When we use Symfony's Console component to write CLI commands in PHP (and you should!), we're almost always writing any output to "stdout". There's a few ways to get general output from a CLI command using Console: // Run the command (Laravelish) public function fire()…

Blogs fideloper.com 136mo ago
55
Functional Library: Null

Functional Library: Null Tony Hoare famously described the invention of null references as a Billion Dollar Mistake. Nulls are something we need to deal with in almost any language. Any value that can be null must be null checked. An example of a very common error that will aris…

Blogs igor.io Igor Wiedler 73mo ago
56
Functional Library: Traversal

Functional Library: Traversal Traversing associative data structures in PHP is fun. Said no one ever. The problem is a common one if you’re processing any kind of data, for example a response from a JSON API. You need to access some nested structure, but you don’t know if what y…

Blogs igor.io Igor Wiedler 73mo ago
57
Functional Library: Iteration

Functional Library: Iteration Welcome to the functional library. This series will explore the state of functional programming in PHP and highlight some libraries for common tasks. This post will look at iteration and lazy operations based on a sequential abstraction. Sequence Ye…

Blogs igor.io Igor Wiedler 73mo ago
58
S-expressions: Macros

S-expressions: Macros (sexpr  lexer  reader  eval  forms  special-forms  macros  walker  meta-eval) The interpreter is functioning, it is able to calculate the fibonacci sequence recursively. And probably almost anything else you would want to. So what is the next step? We have …

Blogs igor.io Igor Wiedler 73mo ago
59
S-expressions: Forms

S-expressions: Forms (sexpr  lexer  reader  eval  forms  special-forms  macros  walker  meta-eval) The previous post introduced a basic implementation of evaluation that is lacking on many fronts. It currently only supports s-expressions which are function applications. The obje…

Blogs igor.io Igor Wiedler 73mo ago
60
Packages in programming languages

Introduction With modular programming, concerns are separated such that modules perform logically discrete functions, interacting through well-defined interfaces. The module / package concept is formally supported by wide range of programming languages but many of them support p…

Blogs brzuchal.com Michał Brzuchalski 84mo ago
61
Array Repack Operator in PHP Concept

Presenting concept of array operator which repacks array by keys to newly created array. I’ve called it Array Repacking because such functionality will produce new array based on original array just with some few improvements. Syntax Proposed syntax doesn’t break any…

Blogs brzuchal.com Michał Brzuchalski 112mo ago
62
Simple Dic With Object Typehint

Following the raging success of PHP 7.0 additions scalar type hints and return types, there is also place for object typehint and return type. That feature can replace double is_object() validation inside function/method. I decided to write an RFC:Object-typehint. Why do we need…

Blogs brzuchal.com Michał Brzuchalski 121mo ago
64
When to use empty in PHP? I'd say never

I realized that I am very strict about the use of PHPs empty function in code review. There isn't really any reason to use it in my opinion: it tests both for the existance and the non-falsy value and as a reader the writers intent is not clear. it does not communicate what type…

Blogs beberlei.de Benjamin 66mo ago
67
How to implement Functional Test in Symfony 4 with Kahlan 4

In this tutorial, we are going to discuss about how to implement the functional testing in Symfony 4 with Kahlan 4. In IT world, whenever we are creating an application/website, we need to test the application/website thouroghly. To perform the functional testing we have a bundl…

Blogs phpcmsframework.com PHP CMS Frameworks 54mo ago
68
TZ Portfolio - A joomla portpolio component / Module / Plugin download

TZ Portfolio works on database of comcontent, sothat you do not have to worry about importing or exporting data from your system (which already works with comcontent). TZ Portfolio inherits all current functions of com_content, in addition, we develop two new data interfaces: Po…

Blogs phpcmsframework.com PHP CMS Frameworks 132mo ago
69
Myth #25: Aesthetics are not important if you have good usability

There are usability practitioners who completely dismiss the importance of aesthetics, often citing unattractive but popular websites such as Craigslist. However, aesthetics do have a function. Attractive things work better. Studies show that emotions play an important role in t…

Blogs uxmyths.com 193mo ago
70
Myth #16: Search will solve a website's navigation problems

On a website, people usually scan for trigger words first and only use the search function when they’re unable to find a good enough navigational link. This holds true for most websites, though people habitually search by default for books, DVDs and CDs, computer games; th…

Blogs uxmyths.com 196mo ago
74
PHP 8.5 Pipe Operator

PHP 8.5 shipped with a feature that functional programming enthusiasts have been requesting for years: the pipe operator (|>). If you’ve used pipes in Unix shells, Elixir, F#, or even JavaScript proposals, the concept will feel immediately familiar. If you haven’t…

Blogs Eric Van Johnson 1mo ago
75
Is spying on mocks a bad practice for unit tests?

For a long time, I have been trying to include tests in every project in which I've worked on. There are several types of automated tests (or what should actually be called automated checks). From unit tests, integration and functional tests, to end-to-end tests. Each one of the…

Blogs alejandrocelaya.blog 86mo ago
76
Default constructors

Consider the following code: class Animal { protected $what = "nothing"; function sound() { echo get_class($this)." says {$this->what}"; } } class Cow extends Animal { protected $what = "moo"; protected $owner; public function __construct($owner)…

Blogs php100.wordpress.com Stas 143mo ago
77
Using AWS Step Functions To Schedule Or Delay SNS Message Publication

with no AWS Lambda function required A co-worker at Archer asked if there was a way to schedule messages published to an Amazon SNS topic. I know that scheduling messages to SQS queues is possible to some extent using the DelaySeconds message timer, which allows postponing visib…

Blogs alestic.com 88mo ago
78
Dependency Injection in JavaScript: A Functional Approach

In my first post, I explained how Dependency Injection (DI) enhances developer experience. If you already know what DI is and you are not convinced that it is worth using in JavaScript, I really encourage you to read it first. In the second post, I discussed why DI is uncommon i…

Blogs goetas.com Asmir Mustafic 13mo ago
79
Simple PHP Routing for Invoice Management System

In this post, we are going to implement a simple router functionality so we can handle HTTP GET requests and render different information based on the page we are currently in. The post Simple PHP Routing for Invoice Management System first appeared on Max Pronko.

Blogs maxpronko.com Max Pronko 41mo ago
80
10 Best AI Coding Tools in 2025 to Code Smarter, Faster, and Error-Free

The era of AI-assisted coding has arrived—and 2026 is the year it goes mainstream. From writing full functions to debugging and documenting complex projects, today’s AI coding tools are reshaping how developers work. Whether you’re a beginner building your first app or a seasone…

Blogs misfitgeek.com Nick Cullen 9mo ago
82
Optimize Your PHP Code: 8 Functions You Need for Efficient Table Handling

Photo by Ben Griffiths on UnsplashIf you want to become a good PHP developer, you must learn to work with arrays. Arrays are used a lot in PHP: temporarily store, organize, and process data before it’s saved in a database. Knowing how to work with them efficiently will help you …

Blogs medium.com Imen Ezzine 16mo ago
83
How to generate a PDF file in a few lines of code with Symfony

Creating dynamic PDF documents, such as invoices or reports, is a common task in modern application development. Whether it’s to meet administrative needs, automate processes, or simply provide essential functionality to users, choosing the right tool for generating these docume…

Blogs medium.com Steven Renaux 20mo ago
85
Using Codeception for Symfony Projects

Codeception Testing Framework from its roots was a plugin of symfony 1 framework. Today Codeception is powered by Symfony components and can be used to run functional tests for practically any popular PHP framework. Why would you someone ever choose Codeception if Symfony alread…

Blogs codeception.com Michael Bodnarchuk 132mo ago
87
JavaScript Testing Tool Showdown: Sinon.js vs testdouble.js

When unit testing real-world code, there are many situations that make tests hard to write. How do you check if a function was called? How do you test an Ajax call? Or code using setTimeout? That’s when you use test doubles — replacement code that makes hard to test things easy …

Blogs codeutopia.net Jani Hartikainen 113mo ago
88
Simplify your JavaScript code with normalizer functions

Everyone loves a good if-else tower! What could be simpler than nesting a few conditionals? if(stuff) { if(more stuff) { haha(); } else { cool(); } } Ok - that isn’t the most amazing thing in the world. In a simple example like this, it isn’t too bad. But we all know real code i…

Blogs codeutopia.net Jani Hartikainen 114mo ago
89
Organizing test code in PHP

Organizing test code in PHP You are working on a PHP application or a package. You have decided that you want to use: infection/infection for running mutation tests phpbench/phpbench for running performance tests phpunit/phpunit for running unit, integration, functional, and end…

Blogs localheinz.com Andreas Möller 41mo ago
90
Pretty-printing JSON with custom indentation

Pretty-printing JSON with custom indentation PHP 5.4 added the JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, and JSON_UNESCAPED_UNICODE constants for use with the json_encode() function. For example, you can use the JSON_PRETTY_PRINT constant to encode a value to a JSON string with…

Blogs localheinz.com Andreas Möller 104mo ago
91
Creating custom Facade fakes in Laravel

I recently released a new version of my Cloudflare Turnstile package for Laravel. One of the features I added was the ability to test your Turnstile integrations using a fake implementation of the Turnstile client. it('validates data', function () { Turnstile::fake(); [code! foc…

Blogs ryangjchandler.co.uk 9mo ago
92
Get a random element from a JavaScript array

To get a random element from an array, you can use a couple of Math functions to generate a random index and retrieve a value. function random(items) { return items[Math.floor(Math.random() * items.length)] } How it works Math.random() generates a random float between 0 and 1. T…

Blogs ryangjchandler.co.uk 30mo ago
93
Fade Between Images with jQuery

With this PHP function, you can fade directly from one image to another with jQuery, and even make a looping slideshow. Super easy.

Blogs inkplant.com 97mo ago
97
Get Redirect URL with PHP

This function follows redirects (even multiple redirects) and returns the final destination URL as a string.

Blogs inkplant.com 117mo ago
98
Don't skip `else` with octane

I came across a subtle Octane but last week. We needed to disable Inertia’s history encryption in some places in the app. By default, it’s enabled everywhere. So we added a route check to the middleware to turn it off. class HandleInertiaRequests { public function ha…

Blogs sebastiandedeyne.com Sebastian De Deyne 1mo ago
99
Introducing Piper: a pipe operator-first PHP utility library

When I experimented with Elixir a few years ago, I fell in love with the pipe operator |>. Since then, I’ve always dreamt of a similar tool in PHP. Last year, we finally got it! Unfortunately, the standard array & string manipulation functions in PHP aren’t ex…

Blogs sebastiandedeyne.com Sebastian De Deyne 2mo ago
100
Want Clean Code? Just Use Functions.

Earlier on in my programming career, I got pretty heavy into Object-Oriented Programming and all the various design patterns around it (there are a lot). I used to worship at the alter of Martin Fowler and zealously look for opportunities to implement all of the various Gang of …

Blogs vancelucas.com vlucas 14mo ago