kandi X-RAY | php-src Summary
kandi X-RAY | php-src Summary
The PHP Interpreter
Top functions reviewed by kandi - BETA
php-src Key Features
php-src Examples and Code Snippets
Trending Discussions on php-src
I want to explore PHP variables on C level with FFI. Is it possible?
I wrote code, but it doesn't work correctly.
ANSWERAnswered 2022-Feb-19 at 16:32
You can't pass PHP variable to FFI C function, but you can access that variable in C code:
http_response_code function sets the header to the defined code and corresponding message from this map http_status_codes.h.
Is it possible to get the message?...
ANSWERAnswered 2021-Dec-19 at 13:26
Under Apache, you may try with
apache_request_headers(). Otherwise, that information might well not be available at all (i.e. sent directly to whatever HTTP serving tier is there, out-of-band and unseen from ob_* functions).
I don't think a definite general answer is possible without delving into the actual source code though.
how do you get DOMDocument when compiling php7.4 from source? i'm on Amazon Linux 2 and compiling php7.4 like this:...
ANSWERAnswered 2021-Dec-03 at 16:49
when compiling with --disable-all, you need both
--enable-dom for DOMDocument to be available.
Is there a way to undo the actions of
sudo make install? That is, remove the files that were copied to the
I built PHP from source using the following commands:...
ANSWERAnswered 2021-Nov-23 at 21:58
make install is not a constant command that magically install a C project. It follows a spec. file that contains instructions to how
make should behave that's called a "Makefile".
In order to undo what
make install did, you must read the Makefile that's located under the project's root directory. see what
install target does and create (if doesn't exist) a target (eg.
uninstall) that reverses all that
install does. (eg. remove installed file, detach Kernel hook, ...etc.).
My previous question (ob_get_status() has undocumented bits set in 'flags' entry) revealed that there are some undocumented flags that may be passed into output buffer callback functions (i.e. the function specified when setting your output buffer, using
One of these flags (undocumented, but revealed by the PHP source code) is
PHP_OUTPUT_HANDLER_DISABLED and this is what I am receiving when I call
ob_get_status(true) in my application.
My question is, what are the situations that can cause an output buffer to be marked as disabled?
(Note that I am asking in the general case, rather than specifically asking about my code, as I feel that too much context would be required to give a specific answer. If I understand the possible reasons, I hope I can deduce which of them might apply in my situation.)...
ANSWERAnswered 2021-Nov-05 at 11:31
I think I've cracked it!
It looks like there is a bug in PHP >= 5.4 that affects the way
false is handled when returned from an output buffer callback function after a 'clean' operation.
The documentation states:
If callback returns false original input is sent to the browser.
This statement implies that the following two callbacks are always identical:
I try to make the following code in ReactJs (not NodeJs) but this doesn't work in JS.
The original code in PHP works fine:...
ANSWERAnswered 2021-Feb-05 at 09:23
The PHP implementation uses
EVP_BytesToKey() as key derivation function and is thus compatible with the CryptoJS key derivation.
However, CryptoJS applies MD5 as digest by default, while the PHP code uses SHA256 (note that OpenSSL has changed the default digest from MD5 to SHA256 as of version v1.1.0).
Moreover, the password applied for the key derivation function is not the password itself (i.e. Nootric2703202) but the hex encoded SHA256 hash of the password.
If this is taken into account, decryption with CryptoJS is:
Basically, how can I can combine these two operations?...
ANSWERAnswered 2020-Dec-20 at 08:13
This is not possible - the Json Patch spec only allows for adding singular values.
As PHP session handler was somehow flawed in the past, we developed a homemade session handler years ago. But it seems that current versions of PHP are well developed and flaws are gone, and we decided to use PHP's default session handler (as it is much faster than our handler which uses dbms to save session data - which sometimes have to read/write megabytes of data).
The only question which we couldn't find an answer for is if PHP's default session handler is atomic or not?
We know that the session files are locked so are prone to race condition, but what about atomicity? What if megabytes of data are going to be saved in a session file, and some errors happens in the middle (power outage, crash or disk failure for example). What happens now? are session data corrupted now? Or old data are still in place?
We don't have a C programmer in our team, but I looked in PHP's source code and I found the line that is responsible for writing sessions to files, but I was unable to find s_write()'s source code's file....
ANSWERAnswered 2020-Oct-28 at 07:14
After some digging in the source, I've found the function that writes the data to the disk.
3 functions can be used by
ps_files_write to write data:
_write, on Win32
prwite, which seems to be a UNIX function, I don't know much about that one honestly.
write, the basic C system call.
As per the links above, all of them are "atomic" in the way that they do not flush the write buffer if an error has been encountered (not enough disk space, unauthorized access, locked file, etc.).
ps_files_write returns an status value (either
FAILURE) which is then later on checked in
php_session_save_current_state to return an
ERROR to the PHP script.
So yes, generally you can consider session writes to be "atomic", even though on some cases you will not be able to guarantee it (if the power is cut suddenly, the system stops within microseconds, so nothing can be saved...).
I recently needed to do multithreading with PHP so I compiled version 7.4 from source to have ZTS mode enabled (required to use Parallel new extension) :
I cloned the PHP source repo on my server
git checkout PHP-7.4
I took this configuration string from a tutorial, I have to admit that I didn't really understand all the options :
CONFIGURE_STRING="--prefix=/etc/phpzts --with-bz2 --with-zlib --enable-zip --disable-cgi
--enable-soap --enable-intl --with-openssl --with-readline --with-curl --enable-ftp
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-sockets
--enable-pcntl --with-pspell --with-enchant --with-gettext --with-gd --enable-exif
--with-jpeg-dir --with-png-dir --with-freetype-dir --with-xsl --enable-bcmath
--enable-mbstring --enable-calendar --enable-simplexml --enable-json --enable-hash
--enable-session --enable-xml --enable-wddx --enable-opcache --with-pcre-regex
--enable-cli --enable-debug --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data
--with-mcrypt --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --enable-parallel
make && make install
copied php.ini file from the php-src repo to phpzts/config (confimed it was loaded successfully by doing a
All the functions that are supposed to be loaded from php extensions work well in my scripts, especially mb_string functions, openssl functions, parallel functions. That's what I don't understand. I was expecting to install them through
apt-get install php7.4-mbstring for exemple, just like what I do with the other php installed for apache. All the extensions are commented in the php.ini file template that I just copied from the source repo :
ANSWERAnswered 2020-Aug-05 at 19:49
You have compiled the modules static to the php binary. Look here http://www.phpinternalsbook.com/php5/build_system/building_extensions.html
As you already know from the previous section, PHP extensions can be either built statically into the PHP binary, or compiled into a shared object (.so). Static linkage is the default for most of the bundled extensions, whereas shared objects can be created by explicitly passing --enable-EXTNAME=shared or --with-EXTNAME=shared to ./configure.
I'm trying to tweak my Kubernetes-based app to make it more development-friendly. I'm using
kustomize to add some extra containers into my
app-deployment. It looks like this:
ANSWERAnswered 2020-Jul-29 at 23:41
No, Kuberentes mounts, unlike Docker mounts do not allow mounting one directory over the other. Potential
VOLUME lines from the
Dockerfile do not matter.
A common solution for your use-case is, to use an init container to set up the emptyDir, before the main container is started. So basically you specify the
emptyDir as a volume mount in both the init container and the main container and have the init container copy the files into the
Additionally, there are two projects that offer different solutions to what you are trying to achieve:
Using one of those you would not need the custom
rsync and init container setup in your overlay.
No vulnerabilities reported
Reuse Trending Solutions
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page