Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does it appear that PHP core functions have empty blocks?

Tags:

php

I'm digging through PHP (using PHPStorm) to figure out how Exceptions work, and I keep running across an interesting situation where functions have empty blocks.

For example, in PHP Runtime/Core/Core.php, the error_reporting function is defined like this:

function error_reporting ($level = null) {}

And it's not unique. The top of that files goes like this (ignore all the documentation comments):

<?php

// Start of Core v.5.3.6-13ubuntu3.2

function zend_version () {}

function func_num_args () {}

function func_get_arg ($arg_num) {}

function func_get_args () {}

function strlen ($string) {}

Why are the braces all empty? Looking through other core files, I see a lot of function definitions, but no actual code. Where is everything?

like image 956
amflare Avatar asked May 25 '26 06:05

amflare


1 Answers

The "Core" files you're looking at are supplied with PHPStorm to support autocompletion. They aren't actually used by the PHP interpreter. These functions are actually all implemented within the PHP interpreter, in native C code.

The real definition of error_reporting, for instance, is in Zend/zend_builtin_functions.c. It's unlikely to tell you much unless you're quite familiar with PHP internals, though.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!