Search
 
SCRIPT & CODE EXAMPLE
 

PHP

-> in php

// Create a new instance of MyObject into $obj
$obj = new MyObject();
// Set a property in the $obj object called thisProperty
$obj->thisProperty = 'Fred';
// Call a method of the $obj object named getProperty
$obj->getProperty();
Comment

$$ in php

$x = "abc";  
$$x = 200;  
echo $x."<br/>";  
echo $$x."<br/>";  
echo $abc; 

// output:
abc
200
200
Comment

:: in php

/*
The Scope Resolution Operator (also called Paamayim Nekudotayim) 
or in simpler terms, the double colon, is a token that allows 
access to static, constant, and overridden properties or methods 
of a class.
*/
class MyClass {
    const CONST_VALUE = 'A constant value';
}

$classname = 'MyClass';
echo $classname::CONST_VALUE;

echo MyClass::CONST_VALUE;
Comment

-> in php

// Create a new instance of MyObject into $obj
$obj = new MyObject();
// Set a property in the $obj object called thisProperty
$obj->thisProperty = 'Fred';
// Call a method of the $obj object named getProperty
$obj->getProperty();
Comment

: in PHP

/*
This is an easy way to execute conditional html / 
javascript / css / other language code with 
php if else:

No need for curly braces {}
*/
<?php if (condition): ?>

// html / javascript / css / other language code to run if condition is true

<?php else: ?>

// html / javascript / css / other language code to run if condition is false

<?php endif ?>
Comment

? in php

/* 
in php, ? is the 'Ternary Operator'.

The expression (expr1) ? (expr2) : (expr3) evaluates 
to expr2 if expr1 evaluates to true, and expr3 if 
expr1 evaluates to false.

It is possible to leave out the middle part of the 
ternary operator. Expression expr1 ?: expr3 evaluates 
to the result of expr1 if expr1 evaluates to true, 
and expr3 otherwise. expr1 is only evaluated once in 
this case.
*/

<?php
// Example usage for: Ternary Operator
$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];

// The above is identical to this if/else statement
if (empty($_POST['action'])) {
    $action = 'default';
} else {
    $action = $_POST['action'];
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: Drupal 9 loop term objects to retrieve term data (id, name, uuid) 
Php :: string length php online 
Php :: multible many routes same controller 
Php :: php how to use multi byte functions 
Php :: array inserted in laravel 
Php :: wp woocommerce change product tags to checbox 
Php :: php 5.6 xampp 
Php :: remove public from url laravel 8 
Php :: laravel where search like with space 
Php :: Laravel adimin - Form is editing or creating 
Php :: create procedure with pdo php 
Php :: What is the method of querying from two tables with a condition in Laravel 
Php :: echo alphabet links 
Php :: wp clean db terms 
Php :: artisan call composer dump in controller 
Php :: nl_langinfo — Query language and locale information 
Php :: wp php blog info background image 
Php :: learndash logo link 
Php :: laravel rename file if exists 
Php :: namespace autoload php 
Php :: codeigniter 4 base_url 
Php :: Comment supprimer les éléments liés à WordPress oEmbed 
Php :: Database connection use for validation in laravel 8 
Php :: encode string for csv 
Php :: Drupal config_readonly 
Php :: faire un fichier zip en php 
Php :: beanstalk run laravel command 
Php :: create product model in laravel 
Php :: Converting hiec to jpg using javascript before uploading in PHP 
Php :: laravel eloquent order by relationship 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =