• Sorular
  • Etiketler

PHP bir sistem çağrısı yaparken nasıl ortam değişkenleri belirtebilirim?

1 Cevap php

Ben "foo" çalıştırıldığında erişimi olacağı PHP system("foo") diyoruz ama aynı zamanda çevre değişkenleri belirtmek isterim. Bu, Linux altında.

Bunun için herhangi bir basit hile?

1 Cevap

putenv("UNIQID=$uniqid");


The PHP Manual, Function Reference, putenv : gelen Atıflar

For example, if a particular system command required a special value
of the environment variable LD_LIBRARY_PATH to execute successfully,
then the following code might be used on a *NIX system:

<?php
 $saved = getenv("LD_LIBRARY_PATH");        // save old value
 $newld = "/extra/library/dir:/another/path/to/lib";  // extra paths to add
 if ($saved) { $newld .= ":$saved"; }           // append old paths if any
 putenv("LD_LIBRARY_PATH=$newld");        // set new value
 system("mycommand -with args");        // do system command;
                        // mycommand is loaded using
                        // libs in the new path list
 putenv("LD_LIBRARY_PATH=$saved");        // restore old value
?>
0

etiketler

  • php
  • linux
  • Sorular
  • Etiketler
Copyright © 2014

Powered by EvrenWeb Int. Media.