Available PHP Functions

get_defined_functions

Следует ли исключать из результата отключённые функции.

Возвращаемые значения

Эта функция возвращает многомерный массив, содержащий список всех определённых функций, как встроенных (внутренних), так и пользовательских. Внутренние функции будут перечислены в элементе массива $arr[«internal»] , а определённые пользователем — в элементе $arr[«user»] (смотрите пример ниже).

Список изменений

Версия Описание
8.0.0 Значение параметра exclude_disabled по умолчанию было изменено с false на true .
7.0.15, 7.1.1 Добавлен параметр exclude_disabled .

Примеры

Пример #1 Пример использования get_defined_functions()

function myrow ( $id , $data )
return «

$id $data

\n» ;
>

Результатом выполнения данного примера будет что-то подобное:

Array ( [internal] => Array ( [0] => zend_version [1] => func_num_args [2] => func_get_arg [3] => func_get_args [4] => strlen [5] => strcmp [6] => strncmp . [750] => bcscale [751] => bccomp ) [user] => Array ( [0] => myrow ) )

Смотрите также

  • function_exists() — Возвращает true, если указанная функция определена
  • get_defined_vars() — Возвращает массив всех определённых переменных
  • get_defined_constants() — Возвращает ассоциативный массив с именами всех констант и их значений
  • get_declared_classes() — Возвращает массив с именами объявленных классов

User Contributed Notes 11 notes

You can list all arguments using ReflectionFunction class. It’s not necessary to parse selected files/files as suggested by Nguyet.Duc.

Example:
function foo (& $bar , $big , $small = 1 ) <>
function bar ( $foo ) <>
function noparams () <>
function byrefandopt (& $the = ‘one’ ) <>

$functions = get_defined_functions ();
$functions_list = array();
foreach ( $functions [ ‘user’ ] as $func ) $f = new ReflectionFunction ( $func );
$args = array();
foreach ( $f -> getParameters () as $param ) $tmparg = » ;
if ( $param -> isPassedByReference ()) $tmparg = ‘&’ ;
if ( $param -> isOptional ()) $tmparg = ‘[‘ . $tmparg . ‘$’ . $param -> getName () . ‘ = ‘ . $param -> getDefaultValue () . ‘]’ ;
> else $tmparg .= ‘&’ . $param -> getName ();
>
$args [] = $tmparg ;
unset ( $tmparg );
>
$functions_list [] = ‘function ‘ . $func . ‘ ( ‘ . implode ( ‘, ‘ , $args ) . ‘ )’ . PHP_EOL ;
>
print_r ( $functions_list );
?>

Output:
Array
(
[0] => function foo ( &&bar, &big, [$small = 1] )

[3] => function byrefandopt ( [&$the = one] )

At least with PHP 4.2.3 on a GNU/Linux/Apache platform, get_defined_functions() returns user-defined functions as all-lower case strings regardless of how the functions are capitalized when they are defined.

Here’s a useful trick with the get_defined_functions function — show all available functions with a link to the documentation (you can even change the mirror it goes to):

// the number of cols in our table
$num_cols = 3 ;

$ar = get_defined_functions ();
$int_funct = $ar [ internal ];
sort ( $int_funct );
$count = count ( $int_funct );
?>


functions
available on
print $_SERVER [ SERVER_NAME ];
?>
( »
target=»phpwin»>php
version
)

for( $i = 0 ; $i < $count ; $i ++) $doc = $php_host
. «manual/en/function.»
. strtr ( $int_funct [ $i ], «_» , «-» )
. «.php» ;
print »

\n» ;
if(( $i > 1 )
&& (( $i + $num_cols )% $num_cols ==( $num_cols — 1 )))
print «

\n

\n» ;
>
for( $i =( $num_cols -( $count % $num_cols )); $i > 0 ; $i —)
print »

\n» ;
?>

. «\» target=\»phpwin\»>»
. $int_funct [ $i ]
. «
 


Please note that functions created with create_function() are not returned.
(However that might change in a later version)

look at here, list all the defined function on your php-Version and give as well formatted output width links onto the php-manual:

To search for a function.


Search:

if (!empty( $_GET [ ‘search’ ])) echo ‘

‘ . ‘. $_GET [ ‘search’ ] . ‘»>’ .
‘Goto ‘ . $_GET [ ‘search’ ] . » .

‘ ;
>
?>

$country = ‘us’ ;
$functions = get_defined_functions ();
$functions = $functions [ ‘internal’ ];
$num = 0 ;
foreach( $functions as $function ) $num ++;
echo ‘

‘ ;
>
?>

‘ .
number_format ( $num ) . ‘
‘ . ‘. $function . ‘» href http://» rel=»nofollow» target=»_blank»>http://’ . $country . ‘.php.net/’ .
$function . ‘»>’ . $function . » . ‘


This is rather a simple non-confusing script to get the function names linked to its manual page on php.net. Hope it helps someone. Commented script is self explainatory

/*declare a variable to php manual of functions.
change the $lng to the region you want it for,
i-e en/es/de etc etc */
$lng = «es» ;
$url = «http://www.php.net/manual/» . $lng . «/function.» ;

// get defined functions in a variable (it will be a 2D array)
$functions = get_defined_functions ();

// Run nested foreach to get the function names
foreach( $functions as $function ) foreach ( $function as $functionName )

/* Since php manual is using hyphens instead of underscores
for functions, we will convert underscores to hyphen whereever
there is one. */
if( strpos ( $functionName , «_» ) !== false ) $functionForURL = str_replace ( «_» , «-» , $functionName );
> else $functionForURL = $functionName ;
>

Источник

Find function file php

  • Different ways to write a PHP code
  • How to write comments in PHP ?
  • Introduction to Codeignitor (PHP)
  • How to echo HTML in PHP ?
  • Error handling in PHP
  • How to show All Errors in PHP ?
  • How to Start and Stop a Timer in PHP ?
  • How to create default function parameter in PHP?
  • How to check if mod_rewrite is enabled in PHP ?
  • Web Scraping in PHP Using Simple HTML DOM Parser
  • How to pass form variables from one page to other page in PHP ?
  • How to display logged in user information in PHP ?
  • How to find out where a function is defined using PHP ?
  • How to Get $_POST from multiple check-boxes ?
  • How to Secure hash and salt for PHP passwords ?

PHP Array Based

  • Program to Insert new item in array on any position in PHP
  • PHP append one array to another
  • How to delete an Element From an Array in PHP ?
  • How to print all the values of an array in PHP ?
  • How to perform Array Delete by Value Not Key in PHP ?
  • Removing Array Element and Re-Indexing in PHP
  • How to count all array elements in PHP ?
  • How to insert an item at the beginning of an array in PHP ?
  • PHP Check if two arrays contain same elements
  • Merge two arrays keeping original keys in PHP
  • PHP program to find the maximum and the minimum in array
  • How to check a key exists in an array in PHP ?
  • PHP | Second most frequent element in an array
  • Sort array of objects by object fields in PHP
  • PHP | Sort array of strings in natural and standard orders

PHP Function Based

  • How to pass PHP Variables by reference ?
  • How to format Phone Numbers in PHP ?
  • How to use php serialize() and unserialize() Function
  • Implementing callback in PHP
  • PHP | Merging two or more arrays using array_merge()
  • PHP program to print an arithmetic progression series using inbuilt functions
  • How to prevent SQL Injection in PHP ?
  • How to extract the user name from the email ID using PHP ?
  • How to count rows in MySQL table in PHP ?
  • How to parse a CSV File in PHP ?
  • How to generate simple random password from a given string using PHP ?
  • How to upload images in MySQL using PHP PDO ?
  • How to check foreach Loop Key Value in PHP ?
  • How to properly Format a Number With Leading Zeros in PHP ?
  • How to get a File Extension in PHP ?

PHP Date Based

  • How to get the current Date and Time in PHP ?
  • PHP program to change date format
  • How to convert DateTime to String using PHP ?
  • How to get Time Difference in Minutes in PHP ?
  • Return all dates between two dates in an array in PHP
  • Sort an array of dates in PHP
  • How to get the time of the last modification of the current page in PHP?
  • How to convert a Date into Timestamp using PHP ?
  • How to add 24 hours to a unix timestamp in php?
  • Sort a multidimensional array by date element in PHP
  • Convert timestamp to readable date/time in PHP
  • PHP | Number of week days between two dates
  • PHP | Converting string to Date and DateTime
  • How to get last day of a month from date in PHP ?

PHP String Based

  • PHP | Change strings in an array to uppercase
  • How to convert first character of all the words uppercase using PHP ?
  • How to get the last character of a string in PHP ?
  • How to convert uppercase string to lowercase using PHP ?
  • How to extract Numbers From a String in PHP ?
  • How to replace String in PHP ?
  • How to Encrypt and Decrypt a PHP String ?
  • How to display string values within a table using PHP ?
  • How to write Multi-Line Strings in PHP ?
  • How to check if a String Contains a Substring in PHP ?
  • How to append a string in PHP ?
  • How to remove white spaces only beginning/end of a string using PHP ?
  • How to Remove Special Character from String in PHP ?
  • How to create a string by joining the array elements using PHP ?
  • How to prepend a string in PHP ?

PHP Class Based

PHP JSON Based

PHP File Systems Based

Источник

Call to Undefined Function in PHP

Call to Undefined Function in PHP

Many of you have encountered this error several times Fatal error: Call to undefined function function_name() . In today’s post, we are finding out how to unravel this error. But before we solve this problem, let’s understand how PHP evaluates the functions.

There are several ways to define functions and call them. Let’s say you write it in the function.php file and call it in the main.php file.

 // function.php  php  namespace fooNamespace   function foo()   return "Calling foo"  >  > ?>  // main.php include function.php   echo fooNamespace\foo(); ?> 
  1. Relative file name such as fooBar.txt . It will resolve to fooDirectory/fooBar.txt where fooDirectory is the directory currently busy directory.
  2. Relative path name such as subdirectory/fooBar.txt . It will resolve to fooDirectory/subdirectory/fooBar.txt .
  3. Absolute path name such as /main/fooBar.txt . It will resolve to /main/fooBar.txt .

    Unqualified name/Unprefixed class name:

$a = new fooSubnamespace\foo(); 
fooSubnamespace\foo::staticmethod(); 
\foonamespace\foo::staticmethod(); 

Now suppose you define a class & call the method of a class within the same namespace.

php  class foo   function barFn()   echo "Hello foo!"  >  function bar()   barFn();  // interpreter is confused which instance's function is called  $this->barFn();  >  >  $a = new foo();  $a->bar(); ?> 

$this pseudo-variable has the methods and properties of the current object. Such a thing is beneficial because it allows you to access all the member variables and methods of the class. Inside the class, it is called $this->functionName() . Outside of the class, it is called $theclass->functionName() .

$this is a reference to a PHP object the interpreter created for you, which contains an array of variables. If you call $this inside a normal method in a normal class, $this returns the object to which this method belongs.

Источник

Читайте также:  What is an if else statement in javascript
Оцените статью