rick645
Members-
Posts
84 -
Joined
-
Last visited
rick645's Achievements
Regular Member (3/5)
0
Reputation
-
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?
-
since php doesn't offer anything native, I'd say this is the solution
-
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?
-
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?
-
I was thinking of doing it with a single instruction
-
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?
-
Thanks for the info, even if I already knew these things
-
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
-
-
$ cat main.php <?php spl_autoload('FooBar'); $ cat foobar.php <?php echo basename(__FILE__) . ": LOADED" . PHP_EOL; $ php main.php foobar.php: LOADED OK!!!
-
ok but what means 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-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?
-
What is it for ReflectionAttribute::IS_INSTANCEOF
rick645 replied to rick645's topic in PHP Coding Help
t hanks -
What is it for ReflectionAttribute::IS_INSTANCEOF
rick645 replied to rick645's topic in PHP Coding Help
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 -
What is it for ReflectionAttribute::IS_INSTANCEOF
rick645 replied to rick645's topic in PHP Coding Help
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