Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change php.ini by PHP?

Tags:

php

I want to do the equivalent to the following line in file php.ini, but from PHP.

short_open_tag = On

Is it possible?

I tried this:

<?php
    if (!ini_get('short_open_tag')) {
        ini_set('short_open_tag', 'On');
    }
    $a = 1;
?>

<?=$a;?>

which outputs <?=$a;?>, so it's not working.

like image 697
user198729 Avatar asked Mar 01 '26 08:03

user198729


1 Answers

Yes, ini_set() is what you want.

An example:

if (!ini_get('short_open_tag')) {
    ini_set('short_open_tag', 'on');
}
like image 130
Jay Zeng Avatar answered Mar 03 '26 21:03

Jay Zeng



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!