Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
Differences between echo and print CODE
1.
echo
can take multiple parameters
echo 'one', 'two', 'three', "\n";
2.
print
statement returns 1
$print_returns = print('some text')."\n";
echo "print_returns Value: $print_returns" . "\n";
echo
prints 1 after
print
statement is executed
echo print "123", "\n";
3.
echo
is a little bit faster than
print
by Valeri Tandilashvili
2 years ago
0
PHP
echo / print
4
Hello world CODE
Prints the text
Hello world
echo "Hello world";
Prints the two words one by one
echo "Hello ";
echo "world";
Prints the variable
$greeting
$greeting = "Hello world";
Echo $greeting;
Concatenates the string to the variable
$greeting
$greeting = "hello world!";
Echo $greeting . " Let's get started!";
by Valeri Tandilashvili
2 years ago
11
PHP
echo / print
4
Math functions CODE
Function
min()
finds the lowest value from its arguments
echo min(10, 15, 7, 9, 17)."\n"; // 7
Function
max()
finds the highest value from its arguments
echo max(10, 15, 7, 9, 17)."\n"; // 17
Function
count()
counts all elements in the array
echo count([10, 15, 7, 9, 17])."\n";
Function
round()
rounds a floating-point number to its nearest integer
echo(round(0.75))."\n";  // returns 1
echo(round(0.5))."\n";  // returns 1
echo(round(0.49))."\n";  // returns 0
Function
floor()
rounds the floating-point number down
echo floor(3.3)."\n";// 3  
echo floor(7.84)."\n";// 7 
echo floor(-4.8)."\n";// -5  
Function
ceil()
rounds the floating-point number up
echo ceil(3.3)."\n";// 4
echo ceil(7.84)."\n";// 8
echo ceil(-4.8)."\n";// -4
Function
rand()
generates a random number
echo rand()."\n";
// Generates a random number from the range
echo rand(10, 100)."\n";
Function
sqrt()
returns the square root of a number
echo sqrt(64)."\n";  // 8
Function
pow()
raises 2 to the power of 3
echo pow(2, 3)."\n";  // 8
Function
pi()
Returns PI value
echo pi()."\n";// 3.1415926535898
Function
abs()
returns the positive (absolute) value of a number
echo abs(-12)."\n";
Function
decbin()
converts decimal number into binary
echo decbin(2)."\n";// 10 
by Valeri Tandilashvili
2 years ago
0
PHP
functions
4
How To Install and Use Composer on Ubuntu
First, update the package manager cache by running:
sudo apt update
Next, run the following command to install the required packages:
sudo apt install php-cli unzip
Make sure you’re in your home directory, then retrieve the installer using curl:
cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
Next, we’ll verify that the downloaded installer matches the SHA-384 hash for the latest installer found on the Composer Public Keys / Signatures page. To facilitate the verification step, you can use the following command to programmatically obtain the latest hash from the Composer page and store it in a shell variable:
HASH=`curl -sS https://composer.github.io/installer.sig` 
If you want to verify the obtained value, you can run:
echo $HASH
Now execute the following PHP code, as provided in the Composer download page, to verify that the installation script is safe to run:
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
You’ll see the following output:
Installer verified
If the output says Installer corrupt, you’ll need to download the installation script again and double check that you’re using the correct hash. Then, repeat the verification process. When you have a verified installer, you can continue. To install composer globally, use the following command which will download and install Composer as a system-wide command named composer, under /usr/local/bin:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
You’ll see output similar to this:
All settings correct for using Composer
Downloading...

Composer (version 1.10.5) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
To test your installation, run:
composer
by გიორგი ბაკაშვილი
4 years ago
0
Linux
Laravel
3
Generate a model and a migration, factory, seeder, and controller CODE
You may generate various other types of classes when generating a model, such as factories, seeders, and controllers. In addition, these options may be combined to create multiple classes at once:
# Generate a model and a FlightFactory class...
php artisan make:model Flight --factory
php artisan make:model Flight -f

# Generate a model and a FlightSeeder class...
php artisan make:model Flight --seed
php artisan make:model Flight -s

# Generate a model and a FlightController class...
php artisan make:model Flight --controller
php artisan make:model Flight -c

# Generate a model and a migration, factory, seeder, and controller...
php artisan make:model Flight -mfsc
by გიორგი ბაკაშვილი
4 years ago
1
Laravel
php artisan make
laravel official doc
3
Datepicker format is
MM/DD/YYYY
and Database format is:
Y-m-d
how to format your date to the correct for you db. you can use
Carbon
:
use Carbon\Carbon;

 start_date = Carbon::parse($request->start_date)->format('Y-m-d');
use carbon function in laravel view(Blade template)
  $start_date = \Carbon\Carbon::parse( $item->start_date)->format('m/d/Y');
by გიორგი ბაკაშვილი
4 years ago
1
Laravel
Date
3
Appends the content to the specified file if it exists (if the file does not exist, the function creates the file and writes the content)
file_put_contents($filePath, $content, FILE_APPEND);
Note: if
FILE_APPEND
parameter is not passed, the function overwrites the content.
by Valeri Tandilashvili
4 years ago
0
PHP
functions
3
by გიორგი უზნაძე
4 years ago
0
Git
3
function getValue(data, path) {
    var i, len = path.length;
    for (i = 0; typeof data === 'object' && i < len; ++i) {
        data = data[path[i]];
    }
    return data;
}
Now if you want to access
a.b.c
var prop = getValue(a, ["b", "c"]);
by გიორგი უზნაძე
4 years ago
0
JavaScript
Object
3
The $loop variable also contains a variety of other useful properties:
$loop->index
The index of the current loop iteration (starts at 0).
$loop->iteration
The current loop iteration (starts at 1).
$loop->remaining
The iterations remaining in the loop.
$loop->count
The total number of items in the array being iterated.
$loop->first
Whether this is the first iteration through the loop.
$loop->last
Whether this is the last iteration through the loop.
$loop->even
Whether this is an even iteration through the loop.
$loop->odd
Whether this is an odd iteration through the loop.
$loop->depth
The nesting level of the current loop.
$loop->parent
When in a nested loop, the parent's loop variable.
@foreach ($users as $user)
    @if ($loop->first)
        This is the first iteration.
    @endif

    @if ($loop->last)
        This is the last iteration.
    @endif

    <p>This is user {{ $loop->index }} ) {{ $user->id }}</p>
@endforeach
by გიორგი უზნაძე
4 years ago
0
Laravel
Blade
3
Results: 1580