IMG-LOGO

Tutorial

IMG
AngularJS Modules
30 Nov-2019

Module of AngularJS is defining an application.

The module and it’s container for the different parts of an application.

The module is a container for the application controllers.

Controllers always belong to a module.

Create Module:

Module is created by using the AngularJS function “angular.module”

 

<div ng-app="FirstApp">...</div>
<script>
var app = angular.module("FirstApp", []);
</script>

 

"FirstApp" parameter refers to an HTML element in which the application will run.

Can add controllers, directives, filters, and more, into AngularJS application.

Controller Add

Add a controller to your application, and refer to the controller with the ng-controller directive:

 

Example:

<div ng-app=" FirstApp " ng-controller="Controller">
{{ FirstName + " " + LastName }}
</div>
<script>
var NewApp = angular.module("FirstApp", []);
NewApp.controller("Controller", function($scope) {
$scope.FirstName = "Smith";
  $scope.LastName = "Dawe";
});
</script>

 

We talk about more about Controller next Session

Add Directive

AngularJS has a set of built-in directives which can use to add functionality to your application.

In addition, you can easily to use the module to add your own directives to your applications:

 

Example:

<div ng-app="FirstApp" w3-test-directive></div>
<script>
var Newapp = angular.module("FirstApp ", []);
Newapp.directive("ngsit", function() {
  return {
    template : "It is directive constructor!"
  };
});
</script>

 

Modules and Controllers in Files

It is common in AngularJS applications to put the module and the controllers in JavaScript files.

In this example, "NewApp.js" contains an application module definition, while "Control.js" contains the controller:

 

Example :

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app=" NewApp" ng-controller="Control">
{{ FirstName + " " + LastName }}
</div>
<script src="NewApp.js"></script>
<script src="Control.js"></script>
</body>
</html>
 

myApp.js

var app = angular.module("NewApp", []);

The [] parameter in the module definition can be used to define dependent modules.

Without the [] parameter, you are not creating a new module, but retrieving an existing one.

 

myCtrl.js
app.controller("Control", function($scope) {
  $scope.FirstName = "Smith";
  $scope.LastName= "Dawe";
});

 

Functions can Pollute the Global Namespace

Global functions should be avoided in JavaScript. They can easily be overwritten or destroyed by other scripts.

AngularJS modules reduces this problem, by keeping all functions local to the module.

When to Load the Library

While it is common in HTML applications to place scripts at the end of the <body> element, it is recommended that you load the AngularJS library either in the <head> or at the start of the <body>.

This is because calls to angular.module can only be compiled after the library has been loaded.

 

Example :

<!DOCTYPE html>
<html>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<div ng-app="NewApp" ng-controller="Control">
{{ FirstName + " " + LastName }}
</div>
<script>
var Newapp = angular.module("NewApp", []);
Newapp.controller("Control", function($scope) {
  $scope.FirstName = "Smith";
  $scope.LastName = "Dawe";
});
</script>
</body>
</html>

News

IMG
New in PHP 7.4
News 30 Nov-2019

Why are some programming languages so popular while others are seldom used for project development and sometimes even fall into oblivion? There are plenty of reasons for that. The simplicity of syntax, functionality, development network, and community support affect the demand level for each technology.

As the world of IT is constantly developing, coding technologies have to keep pace with the changing environment by providing new features, updates, and enhancements. This is one of the most important elements of language success.

In our company, I enjoy PHP due to the frequent improvements being performed each year and believe that it will be popular for many years to come. Since the release of PHP 5 in 2004, its performance has doubled and perhaps, even tripled. This is one of the reasons why we use PHP in our software development company.

It’s no wonder that for the second year in a row, PHP is among the top 10 most popular programming languages according to StackOverflow Developer Survey 2019. This year, it took the 8th place which is one rank higher than in the previous year.

In just 7 days, on Thursday, November 28th, we’ll see the new release of PHP — PHP 7.4, which will become one of the most feature-packed versions ever. In this article, I will list and cover the updated features overview of PHP 7.4. Let’s get started!

What’s new in PHP 7.4? PHP features list

1. Arrow functions’ support

Since anonymous functions, or closures, are mainly applied in JS, they seem to be verbose in PHP. Their implementation and maintenance procedures are also more complex.

The introduction of arrow functions’ support will enable PHP developers to dramatically clean up their code and make the syntax more concise. As a result, you will get a higher level of code readability and simplicity. Take a look at the example below.

So, if you previously had to write this piece of code:

function cube($n){return ($n * $n * $n);}$a = [1, 2, 3, 4, 5];$b = array_map('cube', $a);print_r($b);

With PHP 7.4, you will be able to rewrite it in the following way:

$a = [1, 2, 3, 4, 5];$b = array_map(fn($n) => $n * $n * $n, $a);print_r($b);

Thanks to the ability to create neat, shorter code, the web development process will go faster, allowing you to save time.

2. Typed properties’ support

The introduction of typed properties in the next release will likely be considered one of the most important updated PHP features. While previously there was no possibility to use declaration methods for class variables and properties (including static properties), now programmers can easily code it without creating specific getter and setter methods.

Due to declaration types (excluding void and callable), you can use nullable types, int, float, array, string, object, iterable, self, bool, and parent.

If a web developer tries to assign an irrelevant value from the type, for instance, declaring $name as string, he or she will get a TypeError message.

Like arrow functions, typed properties also let PHP engineers make their code shorter and cleaner

3. Preloading

The main purpose of this cool new feature is to increase PHP 7.4 performance. Simply put, preloading is the process of loading files, frameworks, and libraries in OPcache and is definitely a great addition to the new release. For example, if you use a framework, its files had to be downloaded and recompiled for each request.

When configuring OPcache, for the first time these code files participate in the request processing and then they are checked for changes each time. Preloading enables the server to load the specified code files into shared memory. It’s important to note that they will be constantly available for all subsequent requests without additional checks for file changes.

It is also noteworthy to mention that during preloading, PHP also eliminates needless includes and resolves class dependencies and links with traits, interfaces, and more.

4. Covariant returns & contravariant parameters

At the moment, PHP has mostly invariant parameter types and invariant return types which presents some constraints. With the introduction of covariant (types are ordered from more specific to more generic) returns and contravariant (types are ordered from more generic to more specific) parameters, PHP developers will be able to change the parameter’s type to one of its supertypes. The returned type, in turn, can be easily replaced by its subtype.

5. Weak References

In PHP 7.4, the WeakReference class allows web developers to save a link to an object that does not prevent its destruction. Don’t confuse it with the WeakRef class of the Weakref extension. Due to this feature, they can more easily implement cache-like structures.

See the example of using this class:

<?php$obj = new stdClass;$weakref = WeakReference::create($obj);var_dump($weakref->get());unset($obj);var_dump($weakref->get());?>

Also, note that you can’t serialize Weak References.

6. Coalescing assign operator

A coalesce operator is another new feature available in PHP 7.4. It’s very helpful when you need to apply a ternary operator together with isset(). This will enable you to return the first operand if it exists and is not NULL. If not, it will just return the second operand.

Here is an example:

<?php// Fetches the value of $_GET['user'] and returns 'nobody'// if it does not exist.$username = $_GET['user'] ?? 'nobody';// This is equivalent to:$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';// Coalescing can be chained: this will return the first// defined value out of $_GET['user'], $_POST['user'], and// 'nobody'.$username = $_GET['user'] ?? $_POST['user'] ?? 'nobody';?>

7. A spread operator in array expression

PHP 7.4 will give engineers the ability to use spread operators in arrays that are faster compared to array_merge. There are two key reasons for that. First, a spread operator is considered to be a language structure and array_merge is a function. The second reason is that now your compile-time can be optimized for constant arrays. As a consequence, you will have increased PHP 7.4 performance.

Take a look at the example of argument unpacking in array expression:

$parts = ['apple', 'pear'];$fruits = ['banana', 'orange', ...$parts, 'watermelon'];var_dump($fruits);

Also, it will be possible to expand the same array multiple times. Furthermore, since normal elements can be added before or after the spread operator, PHP developers will be able to use its syntax in the array.

8. A new custom object serialization mechanism

In the new version of PHP, two new methods become available: __serialize and __unserialize. Combining the versatility of the Serializable interface with the approach of implementing __sleep / __ wakeup methods, this serialization mechanism will allow PHP developers to avoid customization issues associated with the existing methods. Find out more information about this PHP feature.

9. Reflection for references

Libraries, such as symfony/var-dumper, heavily rely on ReflectionAPI to accurately display variables. Previously, there was no proper support for reference reflection, which forced these libraries to rely on hacks to detect references. PHP 7.4 adds the ReflectionReference class which solves this problem.

10. Support for throwing exceptions from __toString()

Previously there was no ability to throw exceptions from the __toString method. The reason for that is the conversion of objects to strings is performed in many functions of the standard library, and not all of them are ready to “process” exceptions correctly. As part of this RFC, a comprehensive audit of string conversions in the codebase was carried out and this restriction was removed.

Final thoughts

In just a week, PHP 7.4 will be released. There are plenty of new PHP features that reduce memory usage and greatly increase PHP 7.4 performance. You will gain the ability to avoid some previous limitations of this programming language, write cleaner code, and create web solutions faster.

 

Collected Post From : https://medium.com/

 

IMG
What is in PHP 7.4 for Developers?
News

Does PHP, or Hypertext Preprocessor need any introduction? After reigning for more than a decade as the most popular web language that has been integral to the development of many world-famous CMS solutions, PHP is almost everywhere, in every nook and corner of the web. Naturally, when such a language gets a new update, it makes big news. Well, the launch of new PHP 7.4 is almost around the corner. After PHP 7.3 was released in April this year with several improvements in security and performance, now we have got PHP 7.4 Alpha and Beta versions.

Each subsequent PHP version is expected to be a bit faster than the earlier one. The official benchmarks from PHP say that the PHP 7.3 is at least 10% faster than earlier PHP 7.2 version and it comes as a clear proof of why a new PHP upgrade generates so much hope for a PHP development company. After all, PHP is elementary to WordPress and a host of other web languages, CMS solutions, and frameworks.

What PHP 7.4 Will Bring?

Looking back to the earlier version release, it was mainly about boosting performance and delivering a better syntax when PHP 7.3 was released. But then the new version also gave us more readability and maintainability of the code. We already see the new PHP 7.4 is following the same principles making code far less redundant, more reliable and faster in response time.

We have already got the PHP 7.4 Alpha and Beta versions out and before the final release, they gave me enough to figure out the offerings. In a nutshell, PHP 7.4 will provide us a lot of enhancements to use PHP better for all sorts of development tasks.

Let’s have a look at the key offerings of this new PHP update.

1) Arrow Functions

The arrow functions which are also called short functions will give developers more ease as they now need to write shorter code for functions in PHP. Arrow functions allowing only a single expression that also works as the return statement become appropriate options for all types of single-line closure statements used by the PHP programmers.

2) Class Properties

Class properties for the first time are being offered by any PHP version to this day. Without any difficulty and without breaking the code this new feature can be incorporated into older PHP versions as well.

3) Null Coalescing Operations

Null coalescing operations in new PHP 7.4 will help to do away with the code redundancy to a great extent.

4) Weak Reference Support

This feature will help developers to build structures similar to the cache. Weak Reference support in the new PHP version will allow retaining an object reference that can be destroyed as well.

5) Deprecations

Deprecations come as notices to developers for removal of certain functions in the future.

6) Performance Boost

One of the key reasons to opt for the new PHP version is definitely the promise of enhanced and improved performance. PHP 7.4 is built with that promise and so it introduced the performance-boosting feature of preloading to PHP core. This preloading to PHP core is done through an Opcache extension. This feature will make the response time faster as the need for loading scripts following every user request will be completely done away.

PHP 7.4 Alpha Release Features

Much ahead of the actual release of the full version, PHP 7.4 Alpha was released a couple of months before giving us the first picture of what the new PHP release is going to be all about. With this Alpha release, the first fleet of features was unveiled for the developers. Now, the PHP 7.4 Alpha version is available for download from PHP.net.

Let’s have a look at the key features of the PHP 7.4 Alpha version.

-> PHP 7.4 Alpha version unveiled the preloading feature which as we have seen can enhance the PHP websites and web apps to a great extent. By allowing preloading of the functions or classes that like caches will only remain active for a server session, the response time to any user request will be shortened by at least 30~50%, as initial tests confirmed.

-> Apart from the preloading feature, the new version will have PHP FFI extension to accommodate a Foreign Function Interface allowing programmers to incorporate native functions, variables or data structures of the C programming language. This will actually bring more power to PHP programming.

-> With the new PHP Alpha version, the Hash extension will be a permanent part of PHP that cannot be disabled further.

-> The new Alpha version comes with TLS 1.3 support within the support for PHP OpenSSL streams.

-> Apart from the above mentioned, the new PHP 7.4 boasts of a whole array of fixes and value additions.

PHP 7.4 Beta Release Features

PHP 7.4 Beta version has already been released in June this year. Being the first beta version of this new PHP update, it was expected to unveil few other enhancements over and above the Alpha version released earlier. Before the Beta 2 version is released, it is high time to take a note of the key features of PHP 7.4 first Beta release.

-> Arrow functions or Shorter functions for clean single-line statements and functions
-> Preloading feature to boost performance
-> Typed properties in classes
-> Enhanced type variance
-> The null coalescing operation to minimise redundancy of code
-> FFI for better PHP extension development
-> Use of underscores for formatting numeric values
-> Deprecated short open tags
-> A spread operator in arrays

Conclusion

PHP 7.4 is scheduled to be released in November this year. Before that, the features will be finalised with the release of another couple of beta releases in the coming months. The new version is already being looked after by PHP developers worldwide with a lot of expectations and promises.

Originally Published by CMARIX Technolabs.

IMG
SpaceX targets to provide internet coverage possible in mid-2020
News

SpaceX says it plans to begin offering broadband services to customers with its massive internet-from-space initiative, known as Starlink, as early as mid-2020, SpaceNews reports. The company needs to complete six to eight launches, with 60 satellites per ride, in order to get the service up and running, SpaceX president and COO Gwynne Shotwell told reporters during a media roundtable in Washington, DC.

Starlink is SpaceX’s proposed constellation of thousands of satellites, which are designed to orbit at low altitudes above the Earth and beam internet coverage to the surface below. SpaceX has so far secured licensing from the Federal Communications Commission to launch nearly 12,000 satellites into orbit. And just last week, the company submitted another request to an international regulator, the International Telecommunication Union (ITU), asking for radio frequencies to communicate with an additional 30,000 Starlink satellites. That means the company wants the ability to launch an estimated 42,000 satellites into orbit.

THE COMPANY NEEDS TO COMPLETE SIX TO EIGHT LAUNCHES

“As demand escalates for fast, reliable internet around the world, especially for those where connectivity is non-existent, too expensive or unreliable, SpaceX is taking steps to responsibly scale Starlink’s total network capacity and data density to meet the growth in users’ anticipated needs,” a company spokesperson said in a statement in reference to the new ITU filing.

So far, SpaceX has only launched 60 of its Starlink satellites on a single launch in May, and three of those satellites failed sometime after they made it to orbit. SpaceX also wound up taking two of the remaining satellites out of orbit, to prove that the company has the capability to remove the vehicles from space if necessary. However, the remaining satellites raised themselves to higher altitudes and seem to be working. SpaceX CEO Elon Musk tweeted on Monday night that he was going to send a tweet using the Starlink system. “Whoa, it worked!!” he wrote.

There’s still a lot of work to be done before people can start getting internet from Starlink. Apart from launching satellites, SpaceX still needs to finish developing its user terminal, a small device that customers will use to receive broadband signals from the satellites. The company also needs to figure out how it will roll out the service, according to SpaceNews. It’s possible the service will be offered directly to customers, while in some countries, customers will need to sign up for the service through a telecom service provider, according to Shotwell. A price point also needs to be determined.

“This is very different business for SpaceX,” Shotwell said, according to SpaceNews. “It’s leveraging space technology but it’s a consumer business.”

 

Collected From : https://www.theverge.com

Thank You

Course

IMG
CSS Border -
Course - 19 Jun-2019

Properties of CSS Border

Properties of CSS border, allow your style is specify, width, and color of a border element's.

Such as

All sides borders have on.

Red bottom border I have

Rounded borders I have.

Blue left border I have a.

Border Style

The border-style property specifies what kind of border to display.

The listed following values are accepted:

  1. dotted - Defines a dotted border
  2. dashed - Defines a dashed border
  3. solid - Defines a solid border
  4. double - Defines a double border
  5. groove - Defines a 3D grooved border. The effect depends on the border-color value
  6. ridge - Defines a 3D ridged border. The effect depends on the border-color value
  7. inset - Defines a 3D inset border. The effect depends on the border-color value
  8. outset - Defines a 3D outset border. The effect depends on the border-color value
  9. none - Defines no border
  10. hidden - Defines a hidden border

The border-style property can have from one to four values (for the top border, right border, bottom border, and the left border).

Example

p.dotted {border-style: dotted;}

p.dashed {border-style: dashed;}

p.solid {border-style: solid;}

p.double {border-style: double;}

p.groove {border-style: groove;}

p.ridge {border-style: ridge;}

p.inset {border-style: inset;}

p.outset {border-style: outset;}

p.none {border-style: none;}

p.hidden {border-style: hidden;}

p.mix {border-style: dotted dashed solid double;}

Output:

  • A dotted border.
  • A dashed border.
  • A solid border.
  • A double border.
  • A groove border. The effect depends on the border-color value.
  • A ridge border. The effect depends on the border-color value.
  • An inset border. The effect depends on the border-color value.
  • An outset border. The effect depends on the border-color value.
  • No border.
  • A hidden border.
  • A mixed border.

Note: None of the OTHER CSS border properties described below will have ANY effect unless the border-style property is set!

Border Width

The border-width property specifies the width of the four borders.

The width can be set as a specific size (in px, pt, cm, em, etc) or by using one of the three pre-defined values: thin, medium, or thick.

The border-width property can have from one to four values (for the top border, right border, bottom border, and the left border).

6px border-width

Example

p.first {
border-style: solid;
border-width: 5px;
}
p.second {
border-style: solid;
border-width: medium;
}
p.third {
border-style: solid;
border-width: 2px 10px 4px 20px;
}

Border Color

The border-color property is used to set the color of the four borders.

The color can be set by:

name - specify a color name, like "red"

Hex - specify a hex value, like "#ff0000"

RGB - specify a RGB value, like "rgb(255,0,0)"

transparent

The border-color property can have from one to four values (for the top border, right border, bottom border, and the left border).

If border-color is not set, it inherits the color of the element.

Example

p.one {
border-style: solid;
border-color: red;
}
p.two {
border-style: solid;
border-color: green;
}
 
p.three {
border-style: solid;
border-color: red green blue yellow;
}

Border - Individual Sides

From the examples above you have seen that it is possible to specify a different border for each side.

In CSS, there are also properties for specifying each of the borders (top, right, bottom, and left):

Different Types of Border Styles

Example

p {
border-top-style: dotted;
border-right-style: solid;
border-bottom-style: dotted;
border-left-style: solid;
}

Example

p {
border-style: dotted solid;
}
So, here is how it works:

If the border-style property has four values:

border-style: dotted solid double dashed;

top border is dotted

right border is solid

bottom border is double

left border is dashed

If the border-style property has three values:

border-style: dotted solid double;

top border is dotted

right and left borders are solid

bottom border is double

If the border-style property has two values:

border-style: dotted solid;

top and bottom borders are dotted

right and left borders are solid

If the border-style property has one value:

border-style: dotted;

all four borders are dotted

The border-style property is used in the example above. However, it also works with border-width and border-color.

Border - Shorthand Property

As you can see from the examples above, there are many properties to consider when dealing with borders.

To shorten the code, it is also possible to specify all the individual border properties in one property.

The border property is a shorthand property for the following individual border properties:

border-width

border-style (required)

border-color

Example

p {
border: 5px solid red;
}
You can also use border properties for just one side:
Left Border
p {
border-left: 5px solid red;
background-color: lightgrey;
}

 

Bottom Border

p {
border-bottom: 6px solid red;
background-color: lightgrey;
}

Rounded Borders

The border-radius property is used to add rounded borders to an element:

Normal border

Round border

Rounder border

Roundest border

Example

p {
border: 2px solid red;
border-radius: 5px;
}

Note: The border-radius property is not supported in IE8 and earlier versions.

More Examples

All the top border properties in one declaration

This example demonstrates a shorthand property for setting all of the properties for the top border in one declaration.

 

Set the style of the bottom border

This example demonstrates how to set the style of the bottom border.

 

Set the width of the left border

This example demonstrates how to set the width of the left border.

 

Set the color of the four borders

This example demonstrates how to set the color of the four borders. It can have from one to four colors.

Set the color of the right border

This example demonstrates how to set the color of the right border.

Test Yourself with Practices 

Projects