Jump to content

rick645

Members
  • Posts

    84
  • Joined

  • Last visited

Recent Profile Visitors

1,301 profile views

rick645's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Observe this instruction exec("desktop-file-install ..."); // shell command running Let's say that it can be fine, but only with linux/ubuntu (and various compatible distributions). With other operating systems... mmmhhh... that remains to be seen... You might come across it desktop-file-install: unknow command Therefore, there would be no such standard function install_desktop_file(...); // or install_desktop_entry(...); that interfaces directly with the operating system and not with the shell?
  2. since php doesn't offer anything native, I'd say this is the solution
  3. For every problem, we always tend to look for the simplest solution $solution1 = 2 * 5; $solution2 = 2 + 2 + 2 + 2 + 2; for ($i = 1; $i <= 5; $i++) { $solution3 = $i * 2 . PHP_EOL; } Which do you prefer?
  4. For every problem, we always tend to look for the simplest solution $solution1 = 2 * 5; $solution2 = 2 + 2 + 2 + 2 + 2; for ($i = 1; $i <= 5; $i++) { $solution3 = $i * 2 . PHP_EOL; } Which do you prefer?
  5. I was thinking of doing it with a single instruction
  6. dir$ pwd /tmp/tmp.xWJxJWnltu/dir dir$ tree . ├── a ├── b └── c 0 directories, 3 files dir$ cat ../test.php <?php var_dump( 'OUTPUT1', new RecursiveDirectoryIterator( getcwd() ) ); var_dump( 'OUTPUT2', iterator_to_array( new RecursiveDirectoryIterator( getcwd() ) ) ); var_dump( 'OUTPUT3', iterator_to_array( new RecursiveDirectoryIterator( getcwd(), FilesystemIterator::CURRENT_AS_PATHNAME ) ) ); var_dump( 'OUTPUT4', iterator_to_array( new RecursiveDirectoryIterator( getcwd(), FilesystemIterator::CURRENT_AS_PATHNAME . FilesystemIterator::SKIP_DOTS ) ) ); dir$ php ../test.php /tmp/tmp.xWJxJWnltu/test.php:5: string(7) "OUTPUT1" /tmp/tmp.xWJxJWnltu/test.php:5: class RecursiveDirectoryIterator#1 (4) { private $pathName => string(25) "/tmp/tmp.xWJxJWnltu/dir/." private $fileName => string(1) "." private $glob => bool(false) private $subPathName => string(0) "" } /tmp/tmp.xWJxJWnltu/test.php:12: string(7) "OUTPUT2" /tmp/tmp.xWJxJWnltu/test.php:12: array(5) { '/tmp/tmp.xWJxJWnltu/dir/.' => class SplFileInfo#3 (2) { private $pathName => string(25) "/tmp/tmp.xWJxJWnltu/dir/." private $fileName => string(1) "." } '/tmp/tmp.xWJxJWnltu/dir/c' => class SplFileInfo#4 (2) { private $pathName => string(25) "/tmp/tmp.xWJxJWnltu/dir/c" private $fileName => string(1) "c" } '/tmp/tmp.xWJxJWnltu/dir/..' => class SplFileInfo#5 (2) { private $pathName => string(26) "/tmp/tmp.xWJxJWnltu/dir/.." private $fileName => string(2) ".." } '/tmp/tmp.xWJxJWnltu/dir/b' => class SplFileInfo#6 (2) { private $pathName => string(25) "/tmp/tmp.xWJxJWnltu/dir/b" private $fileName => string(1) "b" } '/tmp/tmp.xWJxJWnltu/dir/a' => class SplFileInfo#7 (2) { private $pathName => string(25) "/tmp/tmp.xWJxJWnltu/dir/a" private $fileName => string(1) "a" } } /tmp/tmp.xWJxJWnltu/test.php:21: string(7) "OUTPUT3" /tmp/tmp.xWJxJWnltu/test.php:21: array(5) { '/tmp/tmp.xWJxJWnltu/dir/.' => string(25) "/tmp/tmp.xWJxJWnltu/dir/." '/tmp/tmp.xWJxJWnltu/dir/c' => string(25) "/tmp/tmp.xWJxJWnltu/dir/c" '/tmp/tmp.xWJxJWnltu/dir/..' => string(26) "/tmp/tmp.xWJxJWnltu/dir/.." '/tmp/tmp.xWJxJWnltu/dir/b' => string(25) "/tmp/tmp.xWJxJWnltu/dir/b" '/tmp/tmp.xWJxJWnltu/dir/a' => string(25) "/tmp/tmp.xWJxJWnltu/dir/a" } /tmp/tmp.xWJxJWnltu/test.php:31: string(7) "OUTPUT4" /tmp/tmp.xWJxJWnltu/test.php:31: array(3) { '/tmp/tmp.xWJxJWnltu/dir/c' => class SplFileInfo#5 (2) { private $pathName => string(25) "/tmp/tmp.xWJxJWnltu/dir/c" private $fileName => string(1) "c" } '/tmp/tmp.xWJxJWnltu/dir/b' => class SplFileInfo#4 (2) { private $pathName => string(25) "/tmp/tmp.xWJxJWnltu/dir/b" private $fileName => string(1) "b" } '/tmp/tmp.xWJxJWnltu/dir/a' => class SplFileInfo#3 (2) { private $pathName => string(25) "/tmp/tmp.xWJxJWnltu/dir/a" private $fileName => string(1) "a" } } The output that comes closest to my expectations is OUTPUT4 (everything else is to be discarded). But actually I would like something like this array(3) { [0] => string(25) "/tmp/tmp.xWJxJWnltu/dir/c" [1] => string(25) "/tmp/tmp.xWJxJWnltu/dir/b" [2] => string(25) "/tmp/tmp.xWJxJWnltu/dir/a" } The simplest output!!! Is it possible?
  7. Thanks for the info, even if I already knew these things
  8. I only did a low level test to understand how it works ok, but here we are already at a higher level They could have documented this more clearly
  9. $ cat main.php <?php spl_autoload('FooBar'); $ cat foobar.php <?php echo basename(__FILE__) . ": LOADED" . PHP_EOL; $ php main.php foobar.php: LOADED OK!!!
  10. ok but what means The autoload function being registered. If null, then the default implementation of spl_autoload() will be registered.
  11. In particular https://www.php.net/manual/en/function.spl-autoload-register.php The autoload function being registered. If null, then the default implementation of spl_autoload() will be registered. In particular https://www.php.net/manual/en/function.spl-autoload.php This function is intended to be used as a default implementation for __autoload(). If nothing else is specified and spl_autoload_register() is called without any parameters then this function will be used for any later call to __autoload(). So what? Intuitively, I did some tests, but I didn't understand much $ cat main.php <?php spl_autoload('App'); var_dump(LOADED); $ cat App.php <?php define('LOADED', true); $ php main.php PHP Fatal error: Uncaught Error: Undefined constant "LOADED" in main.php:3 ...mmmhhh... It seems that the file App.php has not been loaded. In practice, what is the use of function spl_autoload()? What does he do?
  12. https://www.php.net/manual/en/language.attributes.reflection.php //... $attributes = $reflection->getAttributes(); //... Do you do this, or am I wrong? This is clear to me !!! But I don't understand what function performs the constant ReflectionAttribute::IS_INSTANCEOF
  13. The page talks about Attribute::TARGET_*[1] and not Attribute::TARGET Anyway, do you know what the constant ReflectionAttribute::IS_INSTANCEOF is for? $ php -r 'echo ReflectionAttribute::IS_INSTANCEOF . PHP_EOL;' 2 So what? [1] Expandable in Attribute::TARGET_CLASS Attribute::TARGET_FUNCTION Attribute::TARGET_METHOD Attribute::TARGET_PROPERTY Attribute::TARGET_CLASS_CONSTANT Attribute::TARGET_PARAMETER Attribute::TARGET_ALL Attribute::IS_REPEATABLE
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.