Monday, September 21, 2020

PHP - chown

    
    chown('/path/to/file', 'user_name');
    

PHP - chmod

    
    chmod('/path/to/file', 0777);
    

PHP - chgrp

    
    chgrp('/path/to/file', 'user_name');
    

PHP - change file permissions

changes the owner of the file
    
    chown('/path/to/file', 'user_name');
    
changes the usergroup of the file
    
    chgrp('/path/to/file', 'user_name');
    
changes the permissions of the file
    
    chmod('/path/to/file', 0777);
    

PHP - array_merge

    
    $array1 = ['a', 'b', 'c'];
    $array2 = ['d', 'e', 'f'];
    
    $array3 = array_merge($array1, $array2);
    
    var_dump($array3);
    
    //output
    array(6) {
      [0] =>
      string(1) "a"
      [1] =>
      string(1) "b"
      [2] =>
      string(1) "c"
      [3] =>
      string(1) "d"
      [4] =>
      string(1) "e"
      [5] =>
      string(1) "f"
    }
    

Linux - chown command

change only owner of the file
    
    chown USER /path/to/file
    
change only group of the file
    
    chgrp GROUP /path/to/file
    
change owner and group of the directory recursively
    
    chown -R USER:GROUP /path/to/dir
    

Sunday, September 20, 2020

Yii2 - render view in another view

view_1.php
    
    echo $this->render('view_2', ['hello' => 'hello world']);
    
view_2.php
    
    echo $hello;
    // output
    // hello world
    

PHP - chown

chown('/path/to/file', 'user_name');