Skip to main content

Posts

Showing posts with the label senior developer

PHP Code Challenge #2 Find the first non-repeating character in a string:

Here's a PHP code snippet to find the first non-repeating character in a string: <?php function firstNonRepeatingCharacter($str) {     $charCount = array();     // Count occurrences of each character in the string     for ($i = 0; $i < strlen($str); $i++) {         $char = $str[$i];         if (isset($charCount[$char])) {             $charCount[$char]++;         } else {             $charCount[$char] = 1;         }     }     // Find the first non-repeating character     for ($i = 0; $i < strlen($str); $i++) {         $char = $str[$i];         if ($charCount[$char] === 1) {             return $char;         }     }     // If no non-repeating character is found     ...

PHP MCQs for Senior Developer - Mercer Mettl Online Assessment

PHP MCQs for Senior Developer - Mercer Mettl Online Assessment  Here are some multiple-choice questions (MCQs) that could be suitable for assessing the skills of a senior PHP developer in a Mettl test: 1. What does PHP stand for? A. Personal Hypertext Processor B. Preprocessed Hypertext Pages C. PHP: Hypertext Preprocessor D. Preprocessor HyperText Programming Correct Answer: C 2. Which of the following functions is used to open a file for writing in PHP? A. fopen("filename", "r") B. fopen("filename", "w") C. fopen("filename", "a") D. file_open("filename", "w") Correct Answer: B 3. What is the purpose of the mysqli_real_escape_string function in PHP? A. Converts special characters to HTML entities B. Escapes special characters in a string for use in an SQL statement C. Validates an email address D. Removes HTML and PHP tags from a string Correct Answer: B 4. In PHP, what is the purpose of the isset() functi...

21 PHP Interview Questions (Mid Senior Level )

Here are some PHP interview questions suitable for someone with 8 years of experience:   1. Explain the difference between include , require , include_once , and require_once in PHP. In PHP, include, require, include_once, and require_once are used to include and evaluate external files in a PHP script. Here are the differences between them: The include statement is used to include and evaluate a specified file during the execution of the script. If the file is not found, a warning is issued, but the script continues to execute. The require statement is similar to include but with a key difference. If the specified file is not found, a fatal error is issued, and script execution is halted. The include_once statement includes and evaluates the specified file, but it ensures that the file is included only once during the execution of the script. If the file has already been included, it will not be included again. The require_once statement is similar to include_once but with ...