Posts

Showing posts from February, 2023

PHP Practice Questions on Functions

Image
  PHP PRACTICE QUESTIONS ON FUNCTIONS       Practice Questions - User defined functions in PHP. These questions give you how to use a basic PHP function. You will also learn how to use loops and some string functions inside the function. Before attempting these questions, first visit our tutorials on PHP functions . 1. Write a function for find big number $a = 5; $b = 6; $c = 2; 2. Write a function to check a given string is empty or not $username = ""; Hint--use strlen function 3. Print sum of 1..10 digits using for loop inside the function 5. Find given number is available in the array or not $n = 5 $numbers = array(6,3,5,4,6,7); Try with both with built-in function/ without built-in function 6. A function that will coverts a given name into upper case (use strtoUpper bultin function) inside your function $cityname = "hyderabad"; 7. print "Hello" 10 times using function and for loop. 8. print all alphabets A-Z using for loop and using chr() builtin

PHP Functions

Image
  Learn Functions in PHP (Part-1)   PART2 PHP provides a plenty of functions. We can create our own functions too, they are called user-defined function. So In PHP, functions can be classified into two types, one is built-in, and the other one is user-defined . In this tutorial, you are going to learn how to create and use your own functions in PHP. You will also learn what are the uses of functions and how many ways you can define your function and how to call those functions. What is a Function in PHP A function is a block of code with some name.  Function will perform some operation ex: addition, subtraction, multiply…etc.,     Advantages of functions: 1. managing programs becomes easy. 2. functions can be reused. So that it saves memory and time. 3. Error handling becomes easy. 4. functions can be used in multiple programs once they defined in one program    Creating Function   Structure of the function function functionName (arguments) {      code to be executed;      return v

Practice Questions on PHP Basics

Image
PHP Practice Questions   Topics: Variables, Conditional Statement, Switchcase, Looping Statements. 1) Write a program to print the given matrix. Use Nested for loop.           123           456           789 2)  Write a program to calculate sum of the digits of above given matrix 3) Find given letter is consonant or vowel, you can use switch case or if-else 4) Compare password, conform password and print both are same or not if same, print “successfully registered”  else print “passwords not matched”. 5)   Based on the gender print profile image 6)  Print in which subject student failed among in 6 subjects ($m1, $m2, $m3, $m4, $m5 , $m6 )     if marks > or equal to 40,  print passed else failed Hint - use if-else with or operator 7)  First check username and password     next, check both system OTP and user OTP are same or     then print “login success”    else     print “login failed”    variables you need             $username, $password, $systemOTP, $userOTP    Hint -- use nested

User submits email to download a file - php

Image
  Accept user details and allow downloading   This tutorial demonstrates how to let users submit contact details to download a file via link. When users clicks a download link, one popup form opened where user can submit his name, email-address and contact number. And automatically it starts file download within a browser.   index.php     <!DOCTYPE html> <html lang= "en" > <head> <!-- popupmodal JS Files --> <link rel= "stylesheet" href= "https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" > <script src= "https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.slim.min.js" ></script> <script src= "https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" ></script> <script src= "https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" ></script> </head> <body>