Tutorials for PHP Function with Parameters or Arguments

What is Function with Parameters or Arguments?

The information or variables included within the function’s parentheses are referred to as parameters. These are used to keep track of values that can be used during runtime. The comma(,) operator allows the user to input as many arguments as he wants. These options are used to accept inputs during runtime. When transferring numbers, such as during a function call, arguments are used. A parameter is a container for parameters that are given to a function. A value supplied to a function is referred to as an argument. In layman’s terms, both parameter and statement have the same meaning. It’s crucial to keep in mind that each parameter must be accompanied with an argument.

PHP functions,Parameters and arguments


function function_name($first_parameter, $second_parameter) {
    executable code;


Setting Default Values for Function parameter:-

In PHP, we may define default arguments for function parameters. If no argument is supplied for a parameter with a default value, PHP will call the function with the parameter’s default specified value.

The default value for the parameter $num in the previous example is 12; if no value is supplied for this parameter in a function call, the default value is used. It’s also required because the option $str has no default value.

Functions with return values:-

Functions can also return values to the portion of the program where they were called. The value is returned to the program section from where it was named using the return keyword. It is possible to return any type of value, including arrays and objects. The return statement also marks the conclusion of the function, stops it from running, and returns the value.

Parameter passing to Functions:-

In PHP, there are two ways to pass an argument to a function.

Pass by Value:– Moving by value changes the value of an argument within a function, while the original value outside the function stays unaffected. This means that a statement that is a duplicate of the original value is transmitted.

Pass by Reference:– As statements are passed via proxy, the original value is transmitted. As a result, the starting value has changed. Using the ampersand symbol in pass by reference, we just transmit the value’s address, where it is kept (&).


Tagged : / / / / / / / / / / / / / /

Tutorials for PHP Functions

What is Functions?

Complete Guide and Tutorials for PHP Functions with example -  DevOpsSchool.com

A function is a segment of code in a program that is written to do a certain task. We should compare functions to workers in a real-world workplace to have a better grasp of how they work. Assume the management delegated the duty of determining the annual budget to one of his employees. So, what will be the outcome of this procedure? The employee would ask his supervisor for data, perform estimations, calculate the budget, and report the results to his superior. Functions work in a similar fashion. They accept data as an argument, process it using a set of statements or operations, and then return the output.

How many Types of Functions in PHP?

Complete Guide and Tutorials for PHP Functions with example -  DevOpsSchool.com

There are Two Types of Functions :-

User Defined Functions:-These capabilities are used by developers and programmers when they need to execute their own logic. This functions are specified with the keyword function, and when a function call is made, a sequence of statements will be written within the function to execute it. Simply type functionname() in the address bar, and the function will be run.

Built-in functions:- These routines offer us with already-built-in library functionality. The PHP installation kit includes several capabilities, making the language more efficient and helpful. To use the function’s attributes, all we have to do is call it when we want the desired outcome. PHP makes use of date, numeric, string, and other built-in functions.

  • String Functions: These PHP features include built-in support for working with strings. Some of the string methods in PHP include strpos(), strncmp(), strrev(), and strlen() ,
  • Date Function: The format is a human-readable UNIX date and time format, and these functions are PHP standard components.
  • Numeric Functions: These functions have their own preset logic for numeric operations that PHP provides. As a result, it will either return a Boolean or a numeric value. Among them are is number(), number format(), round(), and other numeric procedures.

Why we should Use Functions in PHP?

Reusability:- This programming language has a feature that reduces the amount of lines of code that must be written many times. This would save time and effort for the developer or coder. We can put a piece of code in a feature and call it whenever and wherever it’s needed if it has to be used in many locations. This may be done by calling the functions from other programmes or from inside the same package.

Easier Error Detection:- Because the code is written as functions rather than single blocks, any problems may be immediately and readily recognized and rectified.

Easily Maintained:- Because functions are used throughout the program, we may quickly modify any function or line of code in the function, and the change will be reflected. As a result, it is simple to maintain everywhere.

How to create functions in PHP?

Complete Guide and Tutorials for PHP Functions with example -  DevOpsSchool.com

A function is to find a collection of statements in a programmer repeatedly. When a function in a program is invoked, it is simply implemented. There are a few things to keep in mind while creating a user-identified feature.

  • Any word ending in an opened and closed parenthesis is a feature.
  • The function keyword is commonly used to start a name of the function.
  • Type your name followed by a parenthesis to launch a command.
  • The initial letter in a function word cannot be a number. It might start with a letter or an emphasis.
  • The name of a feature is important.


Tagged : / / / / / / / / / / / /

PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version “>= 7.2.5”. You are running 7.1.32.

When you using PHP version 7.1.32 within your Laravel project, then showing this type of error in your project. If you want to update the composer still not solve you problem then After that Follow this trick-

add this line in config object of composer.json file

“platform-check”: false

run php artisan config:cache

then run composer dump-autoload in terminal

Tagged : / / / / / / / / / /

Comments in JavaScript

Two types of Comment

  • Single Line Comment
  • Multi Line Comment

Single Line Comment

Single line comments start with //.
Text between // and the end of the line will be ignored by JavaScript.

// you can assign any type of value
var imvalue = 101;

var imvalue = 101; // assign any type of value

Multi Line Comment

Multi-line comments start with /* and end with /.

Any text between / and */ will be ignored by JavaScript.

Ex: –
/* Comment Here */

Adding // in front of a code line changes the code lines from an executable line to a comment.

var imvalue = 101;
// var imvalue = 101;

Tagged : / /

Initializing Variables in Javascript

Types of Initializing Variable

var roll;
roll = 101; var roll = 101; roll = 101;

var name;
name = “devopsschool.com”; var name = “devopsschool.com”; name = “devopsschool.com”;

price = 125.36;
Initializing Variable var price = 125.36; price = 125.36;

Whatever happens, is optional so only you roll = 101; can also write. Var is not necessary but if you use this is a good practice.

Rules of Initializing Variable

  • Strings are written inside double or single quotes.
  • Numbers are written without quotes.
  • If you put a number in quotes, it will be treated as a text string

Initializing Variable

var ans = true;
var result = false;

Initializing Variable example

var x = 10, y = 20, c = 30;
var fname = “DevOps”, lname = “School”;
var name = “DevOpsSchool”, roll = 101;
var name = “DevOpsSchool”,
roll = 101,
address = “Steel City”;
Tagged : / /

List of Top 5 Web servers in 2021

  1. Apache
  2. Nginx
  3. Cloudflare Server
  4. LiteSpeed
  5. Microsoft-IIS
  1. Apache: The most popular web server is Apache HTTP Server, which is used by 34.1% of websites in 2021. The BuiltWith Internet services corporation has 62,624,313 live websites that use Apache. 

2. Nginx: Is the second most prominent server, accounting for 33.7% of all active websites in 2021. The web server is distributed under a BSD-style license.

3. Cloudflare Server: Supports web protocols, including SPDY and HTTP/2 and acts as a reverse proxy for web traffic. It is getting more and more popular over years with 18% in 2021.

4. LiteSpeed: Uses the same configuration format as Apache HTTP Server and is compatible with most Apache features. An open source variant is also available. As of April 2020, LSWS was used by 47.6% of websites using HTTP/3. It also sees an increasing trend and takes 18% of the total web server usage.

5. Microsoft-IIS: Supports HTTP, HTTP/2, HTTPS, FTP, FTPS, SMTP and NNTP. It took by about 7% of the total web servers in 2021.

What means web server?

  • A Web server is a program that generates and transmits responses to client requests for Web resources.
  • A Web server is a program to satisfy client requests for web resources.

What are Web servers examples?

Web servers examples are: Apache web server, IIS, NGINX, Tomcat, PWS.

What are the different types of Web servers?

The most prominent types of Web Servers available in the markets are:

  1. Apache HTTP Server Web Server
  2. Internet Information Services (IIS) Web Server
  3. Lighttpd Web Server
  4. Sun Java System Web Server
  5. Jigsaw Server Web Server
  6. LiteSpeed server Web Server
  7. Node.js Web Server

What are the functions of Web server?

  • Read any data sent by the user.
  • Look up any other information about the request that is embedded in the HTTP request.
  • Process the request.
  • Generate the result.
  • Format the result inside a document.
  • Set the appropriate HTTP response parameters.
  • Send the document back to the client as HTML file.

Tagged : / / / / / / / / / / / /