Why PHP built-in standard functions have empty body? [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
How is this possible to have an empty body for a function ?
Is this related to C/C++ (that PHP is written with ) ?
Or is it related to CGI mechanism or something like that ?
I want to know how functions work under the hood.
What if I want to add a simple function that returns "Hello world" written in C++ to PHP ?
Thanks in advance.

These are just dummy files (implemented by the IDE) that serve documentation & autocomplete purposes for the builtin functions / classes.
If you want to see how PHP works under the hood, take a look at its source code: https://github.com/php/php-src.
If you want to extend PHP with custom functions, you can write an extension in C++. There are a lot of tutorials on how to get started.

Related

When to use PHP's variable variables? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've been using PHP for some basics Back-End development for a while now. I saw something about interpretations of variables while I was looking for some changes which came with PHP 7. I'm not using them and it would be great if someone can explain why to use them?
What I mean is:
What are the pros of using them?
You use variable interpretation in situations when you need to dynamically reference a variable and don't want to use an array. Generally I would not recommend using it, as you lose benefits such as static code analysis.

How can i disable X-cart 5 Flexy template engine and use PHP? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Flexy is lack of documentation and maybe because of that I really don't like it at all. I want to use regular PHP in my module, is it possibly?
The best solution would be if I could use PHP just for my module, and do not apply it site-wide.
Thank you.
You can defintely do it, though it is not recommended, by overriding display() method in each of your View classes.
The basic implementation is described in \XLite\View\AView class. You can override it in your View class to print in buffer the output of your custom php script like this:
public function display($template = null)
{
include 'custom_php_template.php';
}
While having 'custom_php_template.php' with similar contents:
<?php
echo 'Hello world';
Please note that this is just the simple example and the real logic can be a lot more complex. Also, by using this approach you may need to create or adapt existing caching solution and other things by yourself.

Using C libraries in PHP [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a library written in C that in turn is build upon the GMP library.
I want to know how can I use the library with PHP?
more informally, say I want to use such library with JAVA, I can simply write Java wrappers for the library.
I think php's exec or shell_exec functions can help you out ...
this functions are used for Execute an external program
take a look at this...
http://www.php.net/manual/en/function.exec.php

Is there a way to define global or standard function in php that can be called from anywhere without including the file [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Very frequently, I need to use codes like this to see output clearly:
$a=print_r($var,true);
echo "<pre>$a</pre>";
How can convert this piece of code to a global function (for example:
echopre) in Php so that I can use echopre($data) anywhere in php
program (in my server)?
Thanks,
Don't think you can have PHP load functions everywhere, per default, without inclusion.
However, you can definitely do it with classes (which, other than having to either create an object or directly access with YourClass::echopre() will work out the same).
Check the php config include_path option.
If server administrator is you, you can write custom php extension and add some functions in php. For example I wrote ar_view function, which is alias of print_r with html formatting: https://github.com/akalongman/ar_view

Listing Functions In PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How can i list the all functions i used in my site using php?I used a lot of php functions in my site.If there is any php function to check which functions are used in my site?
Check out doxygen. By running those scripts you will be able to list all functions and classes, and it links them so you can see the usage:
http://www.doxygen.nl/
You can look into running a phpxref on your codebase.
Example of function documentation output

Categories