Malhar Lathkar

Malhar Lathkar

103 Articles Published

Articles by Malhar Lathkar

Page 5 of 11

PHP Callbacks/Callables

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 919 Views

Callbacks are functions or methods that can be called dynamically using their names or references. In PHP, any callable entity (functions, methods, closures) can be passed as a parameter and executed later using built-in functions like call_user_func(). Checking if Something is Callable The is_callable() function verifies if an identifier can be called as a function ? bool(true) bool(false) Using Built-in Functions as Callbacks Built-in PHP functions can be called using call_user_func() ? HELLO WORLD 5 User-Defined Function Callbacks Custom functions ...

Read More

PHP Tags

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 9K+ Views

PHP tags are special markers that tell the PHP parser where PHP code begins and ends within a file. These tags allow you to embed PHP code within HTML documents, enabling server-side processing before the content is sent to the browser. Basic PHP Tags The standard PHP opening and closing tags are . All PHP statements must be written between these tags to be processed by the server. Syntax Example Hello World Short Echo Tags PHP provides a shorthand syntax ...

Read More

PHP Escaping From HTML

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 1K+ Views

PHP allows you to seamlessly mix PHP code with HTML in a single file. When PHP encounters opening HTML block HTML block Every time the PHP parser encounters an opening tag, it starts executing PHP code until it reaches the closing tag. When PHP code contains conditional statements, the parser determines which blocks to execute or skip. Everything outside PHP tags is treated as HTML and processed by the browser. Basic Example The following example demonstrates PHP code embedded within HTML − ...

Read More

PHP Operator Precedence

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 8K+ Views

Operator precedence in PHP determines the order in which operations are evaluated in expressions. Understanding precedence helps you write correct code and avoid unexpected results. For example, in 2+6/3, division happens first (resulting in 2+2=4) because the division operator / has higher precedence than addition +. How Precedence Works When operators have the same precedence level, associativity (left-to-right or right-to-left) determines the evaluation order. You can override precedence using parentheses to force specific operations to execute first − 14 20 PHP Operator Precedence Table The following table lists PHP ...

Read More

PHP Execution Operator

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 2K+ Views

The execution operator in PHP uses backticks (``) to execute shell commands and return their output as a string. This operator provides a convenient way to run system commands directly from PHP code and is functionally equivalent to the shell_exec() function. Syntax The basic syntax involves wrapping the command in backticks ? $result = `command`; Example 1: Directory Listing This example executes a directory listing command and captures the output ? Volume in drive C is Windows 10 Volume Serial Number is 540D-CE99 Directory of C:\xampp\php 01/27/2016 ...

Read More

PHP Error Control Operator

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 2K+ Views

In PHP, the @ symbol is defined as the Error Control Operator. When it is prefixed to any expression, any error encountered by PHP parser while executing it will be suppressed and the expression will be ignored. Example Without Error Control Operator Following code tries to open a non-existing file for read operation, but PHP parser reports warning − The output of the above code is − Hello World PHP Warning: fopen(nosuchfile.txt): failed to open stream: No such file or directory in /home/cg/root/1569997/main.php on line 2 Example With Error ...

Read More

PHP Expressions

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 12K+ Views

Almost everything in a PHP script is an expression. Anything that has a value is an expression. In a typical assignment statement ($x=100), a literal value, a function or operands processed by operators is an expression − anything that appears to the right of assignment operator (=). Syntax $x = 100; // 100 is an expression $a = $b + $c; // $b + $c is an expression $c = add($a, $b); // add($a, $b) is an expression $val ...

Read More

PHP goto Statement

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 6K+ Views

The goto statement in PHP allows you to transfer program control to a specific labeled location within your code. It's typically used within conditional statements like if, else, or switch constructs to control program flow. Syntax statement1; statement2; if (expression) goto label1; statement3; label1: statement4; After statement2, if the expression evaluates to true, program flow jumps to label1. If false, statement3 executes normally. The program then continues with normal execution flow. Example 1: Conditional Jump This example demonstrates jumping to a label based on whether a number is even ...

Read More

PHP Variable functions

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 11K+ Views

Variable functions in PHP allow you to call a function dynamically by storing its name in a variable. When you append parentheses to a variable containing a function name, PHP executes that function. This feature is particularly useful for implementing callbacks, function tables, and dynamic function calls. Note: Variable functions cannot be used with language constructs like echo, include, require, etc. Use function wrappers as a workaround when needed. Basic Variable Function Here's a simple example where a variable stores a function name and calls it ? Hello World ...

Read More

PHP return Statement

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 3K+ Views

The return statement in PHP is used to return control of program execution back to the environment from which it was called. Upon returning, execution continues with the statement following the function call. When a return statement occurs inside a function, execution of that function terminates immediately, passing control back to the calling code. The return statement can optionally include an expression, in which case the value of that expression is returned along with control. If a return statement is encountered in an included script, execution of that script ends immediately and control returns to the script that ...

Read More
Showing 41–50 of 103 articles
« Prev 1 3 4 5 6 7 11 Next »
Advertisements