Which function can be used to determine if a file exists?
Note: There may be more than one right answer.
- is_readable()
- file_exists()
- feof()
- is_file_exists()
Answer:
Which function can be used to determine if a file exists?
Note: There may be more than one right answer.
Answer:
What is the output of the following code?
- <?php
-
- function y($v){
- echo $v;
- }
- $w= "y";
- $w("z");
- $w="x";
- ?>
Options:
Write a program to remove the multiple spaces from the given string
String str = “You are a good boy.”
Output: “You are a good boy”
- <?php
-
- //without pattern mach
- $str = "I am a good boy";
- for ($i = 0; $i < $str_length; $i++) {
- && $str_arr[$i] == ' '
- && $str_arr[$i] == $str_arr[$i + 1]) {
- } else {
- continue;
- }
- }
-
- ?>
Write a program to find the total digits of a integer value without converting them into string
int a = 3421111
output: 7
- <?php
-
- function total_digit_of_integer($int_val) {
- $go_running = true;
- $no_of_digits = 0;
- $nines = 0;
- //make integer to positive
- if ($int_val < 0) {
- $int_val = -($int_val);
- }
- while ($go_running == TRUE) {
- $nines = (int) ($nines );
- if ($int_val > $nines || $int_val == 0) {
- $int_val = ($int_val == 0) ? 1 : $int_val;
- $no_of_digits++;
- $nines = $nines . '9';
- } else {
- $go_running = FALSE;
- }
- }
- return $no_of_digits;
- }
-
- echo total_digit_of_integer(-10);
- ?>