  | 
              
	              
	                
  
    
	 
        [2564] "บักกิเลส" bug-gy/less ตั้งแต่ งวดที่ 3/2 → ...     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                  Quote:ปริศนา buggy งวดที่ 3 ประจำวันที่ 16 กรกฎาคม 2564 
มีวิธีแก้ปัญหามากกว่าหนึ่ง 
  
 
3.1 
buggy 
first seen:
Array to string conversion
Undefined variable
next:
no bug, but full array(remove it)
last:
wrong result value from first "echo" (do fix it)
 
  
 
Code (PHP) 
$vars = get_defined_vars();
$g = array_keys($GLOBALS);
$a = [["z" => "x", "x" => ["x", "y", "z"]], 1];
$b = "y";
$c = "z";
${array_values($a[0])[1]} = 2;
$$b = 3;
$$c = 5;
echo ($x+$y+$z) / count($a, 1);
$vars = array_diff(get_defined_vars(), $vars);
print_r($vars);
 
 
 
Expected output 
2
Array
(
    [a] => Array
        (
            [0] => Array
                (
                    [z] => x
                    [x] => Array
                        (
                            [0] => x
                            [1] => y
                            [2] => z
                        )
                )
            [1] => 1
        )
    [บี] => y
    [c] => z
    [x] => 2
    [y] => 3
    [z] => 5
)
 
  
 
*** ผลลัพธ์ที่ถูกต้อง... แทน "บี" ด้วย "b" ใช้วิธีเลี่ยงเพราะไปซ้ำกับ bbcode ตัวหนา *** 
 
  
 
3.2 
สร้าง mutator method ให้สอดคล้องกับ interface (Interface1) 
สามารถกำหนดและแสดงค่า private property ($vars) จากคลาส A 
แบบ "method chaining" 
 
buggy 
1. Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ';'
2. Cannot instantiate abstract class
3. Class ... contains 1 abstract method and must therefore be declared abstract or implement the remaining methods
4. Undefined property: ...
5. Undefined index: ...
6. Call to a member function get() on null
...
(ไม่จำเป็นต้องเจอทุกข้อ)
 
  
 
Code (PHP) 
interface Interface1
{
    public function set($name, $var);
    public function get($name);
}
abstract class A implements Interface1
{
    private $vars = [];
  
    public function set($name, $var)
    {
        $this->vars[$name] = $var;
    }
}
echo new A->$var;
 
 
  
 
3.3 
ปรับเปลี่ยน 3.2 ให้สามารถกำหนดและแสดงค่า private property ($vars) 
จาก class A ได้ โดยไม่ต้องสร้าง object และไม่จำเป็นต้องเรียกแบบ "method chaining" 
 
buggy 
1. Cannot make non static method Interface1::set() static in class A
2. Using $this when not in object context
3. Access to undeclared static property
...
และอื่นๆ ตามที่เห็น
 
  
 
 
  
 
  Quote:
  
 
 
Az-Steg
   
 
 
  
 
  Quote:ตั้งแต่ bugless งวดที่ 2 เป็นต้นไป จะใช้เทคโนโลยีการจัดเก็บข้อมูลแบบ 2 in 1  (สะดวกอันไหนใช้อันนั้น)
1. Image Processing (Aztec) สแกนหรือใช้ online tools ในการถอด url ไปยัง bugless encrypted (myCompiler)
 
2. Steganography ใช้บริการ JS library ของ stylesuxx
 ขั้นตอนการถอดข้อความซ่อนด้วย Steganography
  
 
 
  
(ทำไปทำมาเริ่มขี้เกียจละ... )
 
 
  Tag : PHP               
                        | 
           
          
            
		
  ประวัติการแก้ไข 2021-07-16 14:23:26 2021-07-16 14:26:27 2021-07-16 14:27:14	
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2021-07-16 14:10:45 | 
                      By :
                          TheGreatGod_of_Death | 
                      View :
                          844 | 
                      Reply :
                          5 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                   Quote:ปริศนา buggy งวดที่ 4 ประจำวันที่ 1 สิงหาคม 2564 
(เริ่มตั้งแต่งวดที่ 4 ส่วนที่เป็น bug/error จะถูกละไว้ในฐานปฏิบัติการทดลอง) 
  
 
4.1 
$z = range(1, 5);
$y = function ($y) {return $y**$y;};
$fn = function ($x, $y, $z) {
    return $x + $y($z);
};
var_export(array_map($fn, 3, $y, $z));
 
 
output 
array ( 0 => 4, 1 => 7, 2 => 30, 3 => 259, 4 => 3128, )
 
  
 
  
 
4.2 
เรียกใช้ private property($variable) ของ MyClass โดยไม่แก้ไขคลาส 
 
Code (PHP) 
// DON'T TOUCH "MyClass" class
class MyClass {
    private static $variable = 'I am private variable!';
}
echo MyClass::variable;
 
 
output 
I am private variable!
 
  
 
  
 
4.3 (ไม่แสดง bug/error) 
ลดการใช้งานหน่วยความจำ (Memory Consumption Reduction) 
จาก >1MB  ทำให้เหลือ <1KB 
 
Code (PHP) 
$before = memory_get_usage();
$time_start = microtime(true);
function render($number) {
	$r = [];
	for ($i = 0; $i < $number; $i++) {
    	$r["name_$i"] = "description_$i";
    }
    return $r;
}
function getRender($render, $key) {
	foreach($render as $k=>$v) {
		if ($k == $key) {
	    	return $v;
	    }
	}
}
$render = render(10000);
echo $render['name_9999'];
$after = memory_get_usage();
echo "<hr>memory usage: ", number_format($after - $before), " bytes<br>";
echo 'execution time: ' . (microtime(true) - $time_start) . ' seconds';
 
 
 
  
 
  Quote:หวย bugless งวดที่ 3 ประจำวันที่ 1 สิงหาคม 2564 
  
 
Bugless 3
                          
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2021-08-01 13:50:57              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2021-08-01 13:49:27 | 
                        By :
                            TheGreatGod_of_Death | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ความรู้นี่ไม่มีที่สิ้นสุดเลยครับ  ">                           
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2021-08-13 20:25:55 | 
                        By :
                            nobody001 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	     
	    
     
      		  
	
     | 
   
 
                 |