AmitDiwan has Published 10744 Articles

How to create a full screen search box with CSS and JavaScript?

AmitDiwan

AmitDiwan

Updated on 08-Apr-2020 11:08:47

617 Views

Following is the code to create a full screen search box with CSS and JavaScript −Example Live Demo body {    font-family: Arial; } * {    box-sizing: border-box; } .showBtn {    background: #008b0c;    border: none;    color:white;    padding: 10px 15px;    font-size: 20px; ... Read More

How to create a form with icons using CSS?

AmitDiwan

AmitDiwan

Updated on 08-Apr-2020 09:31:29

739 Views

Following is the code to create a form with icons −Example Live Demo body {    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } * {    box-sizing: border-box; } h1 {    text-align: center; } form {    max-width: 500px;    margin: auto; } .fieldContainer ... Read More

How to create a contact form with CSS?

AmitDiwan

AmitDiwan

Updated on 08-Apr-2020 09:20:49

486 Views

Following is the code to create a contact form using CSS −Example Live Demo * {box-sizing: border-box;} body{    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } label{    font-size: 15px; } input[type=text], textarea {    width: 100%;    padding: 12px;    border: 1px solid #ccc;   ... Read More

Passing static methods as arguments in PHP 

AmitDiwan

AmitDiwan

Updated on 07-Apr-2020 14:20:40

782 Views

The same syntax used by is_callable and call_user_func can be used to pass static methods as arguments in PHP.To pass the static method, the below example can be used −Example Live Demo OutputThis will produce the following output −bool(true) my_func bool(true)

Pass arguments from array in PHP to constructor

AmitDiwan

AmitDiwan

Updated on 07-Apr-2020 14:19:51

844 Views

The Reflection API can be used to pass arguments from array to constructor.ReflectionClass::newInstanceArgsThe above line creates a new class instance from given arguments −public ReflectionClass::newInstanceArgs ([ array $args ] ) : objectIt creates a new instance of the class when the arguments are passed to the constructor. Here, args refers ... Read More

How to validate domain name in PHP?

AmitDiwan

AmitDiwan

Updated on 07-Apr-2020 13:21:09

1K+ Views

The domain name can be validated using the below code in PHP −Example Live Demo $domain_name = 'https://tutorialspoint.com' is_valid_domain_name($domain_name)OutputThis will produce the following output −$domain_name = 'https://tutorialspoint.com' is_valid_domain_name($domain_name)In the above code, the ‘preg_match’ function is used to match the domain_name passed as an argument to the user-defined function ‘is_valid_domain_name’.Read More

How to install Imagick/imagemagick PHP extension on Windows 10?

AmitDiwan

AmitDiwan

Updated on 07-Apr-2020 13:18:50

286 Views

To install Imagick or Imagemagick on windows, follow the below mentioned procedure −Check the permissions on the .dll file. This will make sure that the Apache user has read access to the file.It is better to change the permission of the [PHP]/extension directory.In order to change the permission, follow the ... Read More

Getting size in memory of an object in PHP?

AmitDiwan

AmitDiwan

Updated on 07-Apr-2020 13:17:10

2K+ Views

The memory_get_usage() function can be caked before and after allocating memory to the class created.class MyBigClass {    var $allocatedSize;    var $allMyOtherStuff; } function AllocateMyBigClass() {    $before = memory_get_usage();    $ret = new MyBigClass;    $after = memory_get_usage();    $ret->allocatedSize = ($after - $before);    return $ret; }Output ... Read More

PHP Call methods of objects in array using array_map?

AmitDiwan

AmitDiwan

Updated on 07-Apr-2020 13:15:01

1K+ Views

In PHP version 5.3, methods of objects in array can be called using the below code −$props = array_map(function($obj){ return $obj->getProp(); }, $objs);This will be slower than a ‘for’ loop since it invokes one function for every element −function map($obj) {    return $obj->getProperty(); } $props = array_map('map', $objs);Alternatively, for ... Read More

Is it possible to have a HTML SELECT/OPTION value as NULL using PHP?

AmitDiwan

AmitDiwan

Updated on 07-Apr-2020 13:12:47

1K+ Views

The short answer is no. POST/GET values are never null. The best they can be is an empty string, which can then be converted to null/'NULL' −Example Live Demoif ($_POST['value'] === '') {    $_POST['value'] = null; } echo'Null assigned';OutputThis will produce the following output −Null assigned

Advertisements