Skip to content

David Peach

This website is 100% maintained and written by a human bean. AI is NOT WELCOME HERE.

  • Programming
  • Notes
  • Now
  • Uses
Scroll down to content

Posts

Posted on 29th May 202211th August 2025

What is the PHP __call magic method?

Consider this PHP class:

<?php
class FooClass
{
    public function bar(): string
    {
        return 'Bar';
    }
}

We could call the bar method as follows:

<?php
$fooClass = new FooClass;

$fooClass->bar();

// returns the string 'Bar'

However, in PHP, we have the ability to call methods that don’t actually exist on a class. They can instead be caught by a “magic method” named __call, which you can define on your class.

<?php
class BazClass
{
    public function __call(string $name, array $args)
    {
        // $name will be given the value of the method
        // that you are trying to call

        // $args will be given all of the values that
        // you have passed into the method you are
        // trying to call
    }
}

So if you instantiated the BazClass above and called a non-existing method on it with some arguments, you would see the following behavior:

<?php
$bazClass = new BazClass;
$bazClass->lolcats('are' 'awesome');

In this example, BazClass‘s __call method would catch this method call, as there is no method on it named lolcats.

The $name value in __call would then be set to the string “lolcats”, and the $args value would be set to the array [0 => 'are', 1 => 'awesome'].

You may not end up using the __call method much in your day to day work, but it is used by frameworks that you possibly will be using, such as Laravel.

Posted on 28th May 20229th July 2025

Lego Aloy

Posted on 28th May 20229th July 2025

Bought the Horizon Forbidden West tallneck lego.

Posted on 18th April 20223rd June 2026

Fierce

Profile shot of a young animated woman. She has black hair, has a fierce look on her face, and is poised with a staff held behind her back, ready to strike something.
Posted on 18th April 20223rd June 2026

Holding her staff

Posted on 17th April 20223rd June 2026

Smiling

Posted on 17th April 20223rd June 2026

Kena looking proud

Posted on 15th April 20225th June 2026

Aloy with red headband

Posted on 15th April 20228th June 2026

Takedown

Posted on 15th April 20228th June 2026

Hand on hip

Posted on 12th April 20223rd June 2026

Into the fog

Posted on 6th April 20228th June 2026

Looking Up

Posts navigation

Previous page Page 1 … Page 31 Page 32 Page 33 … Page 211 Next page
September 2026
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
282930  
« Aug    

Topics / Tags

  • 100 days of new retro wave
  • Albums
  • American Horror Story
  • Am Watching
  • Animals
  • Art
  • Birmingham
  • Birmingham Owls
  • Books
  • Egg
  • Films
  • funny
  • Games
  • gaming
  • Grinding my gears
  • Horror
  • Horror Manga
  • Jams
  • Junji Ito
  • Lana Del Rey
  • Laravel
  • Linux
  • London 2015
  • LOST
  • manga
  • Moomin
  • Music
  • My Website
  • Pets
  • PlayStation
  • Programming
  • PS4
  • Quotes
  • Reading
  • Reviews
  • Running
  • Songs
  • The Walking Dead
  • Tomie Collection
  • Top 500 Albums
  • TV
  • Uzumaki
  • Web Development
  • wordpress
  • Writing

Categories

  • Gaming (372)
    • A Plague Tale: Innocence (2)
    • Alien Isolation (2)
    • Control (3)
    • Cyberpunk 2077 (20)
    • Days Gone (31)
    • Dead by Daylight (9)
    • Death Stranding (14)
    • Death Stranding 2: On The Beach (25)
    • Everybody's Gone To The Rapture (3)
    • God Of War (6)
    • Hellblade: Senua's Sacrifice (9)
    • Horizon Forbidden West (15)
    • Horizon Zero Dawn (77)
    • Kena: Bridge of Spirits (4)
    • No Man's Sky (11)
    • Ratchet and Clank: A Rift Apart (1)
    • Red Dead Redemption 2 (5)
    • Resident Evil 2 (28)
    • Resident Evil 4 (12)
    • Resident Evil 7 (2)
    • Resident Evil Village (12)
    • The Last of Us (27)
    • The Last Of Us part 2 (24)
    • The Long Dark (5)
    • The Witcher 3 (3)
    • Tomb Raider 3 (1)
    • Uncharted 4 (21)
  • Horror Manga Reviews (65)
    • Junji Ito (65)
      • Tomie by Junji Ito (20)
      • Uzumaki by Junji Ito (14)
  • Interviews (13)
  • Journal (91)
  • Music (79)
  • Notes (1,774)
  • Photos (80)
  • Programming (49)
    • Vim (1)

tags

  • 100 days of new retro wave
  • Albums
  • American Horror Story
  • Am Watching
  • Animals
  • Art
  • Birmingham
  • Birmingham Owls
  • Books
  • Egg
  • Films
  • funny
  • Games
  • gaming
  • Grinding my gears
  • Horror
  • Horror Manga
  • Jams
  • Junji Ito
  • Lana Del Rey
  • Laravel
  • Linux
  • London 2015
  • LOST
  • manga
  • Moomin
  • Music
  • My Website
  • Pets
  • PlayStation
  • Programming
  • PS4
  • Quotes
  • Reading
  • Reviews
  • Running
  • Songs
  • The Walking Dead
  • Tomie Collection
  • Top 500 Albums
  • TV
  • Uzumaki
  • Web Development
  • wordpress
  • Writing

TEXT F1

TEXT F2

TEST F2 -2

Proudly powered by ClassicPress