PHP Basic Quiz

A bright and engaging illustration of a computer screen displaying PHP code, surrounded by programming elements like gears and code snippets, conveying a sense of learning and coding.

Test Your PHP Knowledge

Welcome to the PHP Basic Quiz! This quiz is designed to test your understanding of the PHP programming language. Whether you're a beginner looking to sharpen your skills or an experienced developer wanting to reflect on your knowledge, this quiz is perfect for you!

In this quiz, you'll find:

  • Multiple choice questions
  • Code interpretation challenges
  • String manipulation scenarios
15 Questions4 MinutesCreated by CodingMaster320
Apa itu PHP ?
Client Side Programming
Server Side Programming
DB Programming
Assembly-Type Programming
Manakah kode di bawah yang menghasilkan ouput 5?
Echo $i = 5;
$i; echo '5';
$i = 'echo'.5;
Echo '5'.$i;
Berikut ini manakah contoh yang tepat untuk menggabungkan string dalam PHP?
Echo 'Hi'+'Hello'
Echo 'Hi'.'Hello'
Bagaimanakah cara untuk melakukan Block Comment dalam PHP?
// Ini Comment
/* Ini Comment */
-- Ini Comment
<?php
  $i = 5;
  $i = $i.' orang';
  echo $i;
?>
 
Output dari code diatas adalah?
5
5 orang
(kosong)
(error)
<?php
  $i = 5; 
  $i = $i+' orang';
  echo $i;
?>
 
Output dari code diatas adalah ?
5
5 orang
(kosong)
(error)
<?php
  $nilai = 54;
  if($nilai > 50)
    echo 'Excellent';
  else if($nilai == 54)
    echo 'Normal';
  else if($nilai < 50)
    echo 'Bad';
?>
 
Output dari code diatas adalah?
Excellent
Normal
Bad
(error)
<?php
  $colors =array();
  $colors[0] = 'green';
  $colors[1] = 'red';
  $colors[0] = 'blue'; 
?>
 
Bagaimanakah value $colors setelah kode diatas dieksekusi?
$colors = array();
$colors = array('green', 'red', 'blue');
$colors = array('green', 'blue', 'red');
$colors = array('blue', 'red');
$colors = array('green', 'red');
$colors = array('red');
<?php
  $user = array(
    'name' => 'Oki Maulana',
    'class' => 'Computer',
    'speciality' => 'Android Apps',
    'rate' => 8
  );
  
  $students[0] = $user;
?>
 
Bagaimanakah cara menampilkan output dari name "Oki Maulana"?
$user['name']
$user[0]['name']
$students['name']
$students[0]['name']
<?php 
  $employees = array(); 
  $employees[0] = array('name' => 'Chika', 'age' => 27); 
  $employees[1] = array('name' => 'Jaka', 'age' => 30); 
  $employees[2] = array('name' => 'Indri', 'age' => 22); 
  $employees[3] = array('name' => 'Sungkar', 'age' => 23); 
?>
 
Bagaimana cara menampilkan umur dari Indri?
Echo $employees[2]['age'];
Echo $employees['Indri']['age'];
Echo $employees['age']['Indri'];
Echo $employees[2]['age']['Indri'];
<?php 
  $employees = array(); 
  $employees[0] = array('name' => 'Chika', 'age' => 27); 
  $employees[1] = array('name' => 'Jaka', 'age' => 30); 
  $employees[2] = array('name' => 'Indri', 'age' => 22); 
  $employees[3] = array('name' => 'Sungkar', 'age' => 23); 
?>
 
Bagaimana cara menampilkan jumlah dari pegawai/employee?
Echo count($employees);
Echo $employees;
Echo print_r($employees);
Echo $employees.length;
<?php 
  $employees = array(); 
  $employees[0] = array('name' => 'Chika', 'age' => 27); 
  $employees[1] = array('name' => 'Jaka', 'age' => 30); 
  $employees[2] = array('name' => 'Indri', 'age' => 22); 
  $employees[3] = array('name' => 'Sungkar', 'age' => 23); 
 
  for($i = 0; $i <= count($employees); $i++){
    echo '<tr><td>'.$i.</td></tr>;
  }
?>
 
Ada berapa jumlah baris yang tercetak?
0
1
2
3
4
5
6
<?php 
  $employees = array(); 
  $employees[0] = array('name' => 'Chika', 'age' => 27); 
  $employees[1] = array('name' => 'Jaka', 'age' => 30); 
  $employees[2] = array('name' => 'Indri', 'age' => 22); 
  $employees[3] = array('name' => 'Sungkar', 'age' => 23); 
 
  for($i = 0; $i < count($employees); $i++){
    echo '<tr><td>'.$employees[$i]['age'].</td></tr>;
  }
?>
 
Apa tujuan dari program diatas?
Menampilka nama dari pegawai
Menampilkan nomor dari pegawai
Menampilkan umur dari pegawai
Hasilnya kosong
<?php 
  $employees = array(); 
  $employees[0] = array('name' => 'Chika', 'age' => 27); 
  $employees[1] = array('name' => 'Jaka', 'age' => 30); 
  $employees[2] = array('name' => 'Indri', 'age' => 22); 
  $employees[3] = array('name' => 'Sungkar', 'age' => 23); 
 
  for($i = 0; $i <= count($employees); $i++){
    if($employees[$i]['age'] >= 27)
      echo '<tr><td>'.$employees[$i]['name'].</tr></td>;
  }
?>
 
Ada berapa jumlah baris nama pegawai yang tercetak?
0
1
2
3
4
<?php 
  $employees = array(); 
  $employees[0] = array(
    'name' => 'Chika',
    'alamat' => array('kodepos' => 13412, 'rt' => '03', 'rw' => '10')
  ); 
  
  $employees[1] = array(
    'name' => 'Agus',
    'alamat' => array('kodepos' => 11223, 'rt' => '13', 'rw' => '09')
  ); 
  for($i = 0; $i <= count($employees); $i++){
    (.......................)
  }
?>
 
Isilah titik-titik diatas, jika tujuan kita ada untuk menampilkan kodepos dari employee/karyawan.
Echo $employees['kodepos'];
Echo $employees[$i]['kodepos'];
Echo $employees[$i]['alamat']['kodepos'];
Echo $employees[$alamat]['kodepos'];
Echo $employees['kodepos'][$i];
{"name":"PHP Basic Quiz", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Welcome to the PHP Basic Quiz! This quiz is designed to test your understanding of the PHP programming language. Whether you're a beginner looking to sharpen your skills or an experienced developer wanting to reflect on your knowledge, this quiz is perfect for you!In this quiz, you'll find:Multiple choice questionsCode interpretation challengesString manipulation scenarios","img":"https:/images/course8.png"}
Powered by: Quiz Maker