PHP Skill Test
1. Create a PHP class representing a basic calculator with methods for addition,
subtraction, multiplication, and division.
2. Write a PHP script to generate a random password of a given length.
3. Develop a PHP script to consume data from a RESTful API (e.g., GitHub API)
and display it in a web application.
4. You are given an array of integers, where each element represents the stock price
on a given day. You need to design a PHP function maxProfit() to find the
maximum profit that can be achieved by buying and selling the stock at most
once. If no profit can be achieved, return 0.
For example, given the array [7, 1, 5, 3, 6, 4], the function should return 5, as the
maximum profit can be achieved by buying on day 2 (price = 1) and selling on day
5 (price = 6).
Requirements:
• Your solution should have a time complexity of O(n), where n is the
number of elements in the array.
• You can assume that the array will contain at least two elements.
5. Write a PHP script to fetch records from a MySQL database table named posts
and display them on a webpage. Additionally, implement functionality to filter
posts by category using URL parameters.
No comments:
Post a Comment