Blog Archive | Codeexecute

Different Types of PHP errors?

Php error

Php errors, is a kind of mistake or fault. Error or a warning can we occurred due to wrong syntax, missing files or functions, wrong conditions.

In other words, we can say an php errors comes when you write code carelessly.

 

Types of errors:-

Mainly there are four types of php errors

  1. Parse Error
  2. Fatal Error
  3. Warnings
  4. Notices

 

1: Parse Error

Parse error also called syntax error occurs when there is syntax mistake in code. These kinds of errors only generated during compile time and they will stop the expectation of code. The main reason of these kind of errors is writing a code with carelessly.

Common reasons:

  • Missing semicolons
  • Unclosed braces
  • Unclosed quotes
  • Missing or extra parentheses

 

2: Fatal Error

Fatal errors are the major errors and they stop the code execution immediately without any warning. These kinds of error caused when PHP understand our written code but didn’t provide the output what we are asking to do. In this case user can lose their unsaved data.

Common reasons:

  • Attempt an illegal instruction
  • Attempt an invalid code
  • Call undefined functions

 

 

3: Warnings

Warning is kind of messages those indicate that you are doing some wring please fix it. They will not stop the execution.

Common reasons:

  • Include missing files
  • Using incorrect number of parameters

 

4: Notices

Notices are most like the warning. These are small and non-critical errors and they do not affect code execution. By default, these kinds of errors not display to the users.

Common reasons:

  • Access the undefined variable

 

Error Handling: –

Error handing necessary to avoid unwanted results on our pages. They also help to increase the security of our script.

  1. Die Statement
  2. Error reporting
  3. Custom error handlers

 

1: Die Statement

It’s a very common method for error handling. It’s mainly useful when we want to stop the execution and display a message

2: Error reporting

Error reporting is a function having different types of levels.

error_reporting(0);      //Hide all errors

error_reporting(E_ALL);  //Show all errors

error_reporting(-1);     //Show all errors

error_reporting(E_ERROR | E_WARNING | E_PARSE);  // report simple errors

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); //report notices

error_reporting(E_ALL & ~E_NOTICE); //report all errors except notices

 

3: Custom error handlers

Php provides us an option to define custom error handlers to error handling. There are used defined function called when errors occurred.

error_function(error_level,error_message,error_file,error_line,error_context);

  • error_level – required
  • error_message – required
  • error_file – optional
  • error_line – optional
  • error_context – optional
 

Immediately-invoked function expression(IIFE)

Working with Javascript you might have been come accross the code like this:

(function () {
})();

Yes, ofcourse being a JS developer you have seen this code and probably a lot of you know the term used to refer this type of construct. and you guessed it right!!

Immediately-Invoked Function Expression, or IIFE

According to Wikipedia

An immediately-invoked function expression (or IIFE, pronounced “iffy”)is a JavaScript programming language idiom which produces a lexical scope using JavaScript’s function scoping. Immediately-invoked function expressions can be used to avoid variable hoisting from within blocks, protect against polluting the global environment and simultaneously allow public access to methods while retaining privacy for variables defined within the function.

Too much to digest!! Isn’t it? So let’s make it simple by an example

Create a file index.html and paste the follwoing code into it

Here you can see that in console if you type foo You can access that, Since JS is not having any block scope so to avoid the global namespace, We can enclose the complete code in a function which may or may not have a name. Thus enclosed code within this type of function is termed as IIFE.

The first pair of parentheses (function(){...}) turns the code within (in this case, a function) into an expression, and the second pair of parentheses (function(){...})() calls the function that results from that evaluated expression.

Check the below code for reference

Here you can see that in console if you type foo you will get an error

Uncaught ReferenceError: foo is not defined
at :1:1

In this case we just saved our global variable to be encapsulated within function block.

 

Microsoft acquires Github

After acquiring the Job site Linkedin, Microsoft has acquired the world’s leading software development and open source platform Github for $7.5 billion.

microsoft_acquires_github
microsoft_acquires_github

Open source has become the dominant development paradigm and with development of VSCODE microsoft has stepped into the world of open source. 10 years ago when Github was started, it was hard to imagine that a business / enterprise company would acquire an open source organization, but today it is the reality. Github is the most popular version control system, on the other hand Microsoft is the most active organization on Github creating a number of open source project. Microsoft’s biggest open source project VSCODE editor is made on Electron JS which is developed and maintained by Github. So things are interrelated. To summarize with the leading edge of open source community and their supports Microsoft has understood the shared and faster development process of open source community.

And with the recent acquisition of Linkedin Microsoft could also want to access the poo of largest community of smart and talented developers on Github. There could be many other business strategy behind the acquisition of Github, so let’s wait and watch!!!

 

JavaScript Framework : Future of web development

As a web developer, I have noticed that from fast some years JavaScript Frameworks become more popular among the developers.
Let’s find out why they become more and more popular now a days.In this blog we will discuss about their uses, types and their advantages.

Introduction

A JavaScript Framework is an application framework written in JavaScript. JS framework is totally different form JS library as it’s defined the complete app design. JavaScript Frameworks provide us a skeleton like car with body and we need to work on it to make it functional according to the requirement.

Why to use

Although as a developer I would not recommend to use a framework over plain JavaScript.Because you can’t beat Vanilla JS code in terms of performance with respect to any other framework. But remember one thing that these things can’t be compromised with time delivery of your product and hence we needed a framework. To use Vanilla JS you need to have crisp and clear understanding of all the concepts of Vanilla JS. Having experienced with all the good/bad part of JS only you can write a concise and deliverable code otherwise an inexperienced developer will turn out to deliver a buggy and unmaintained code over the time. So in this case using a framework would certainly help you to achieve the desired app in less time. Google, Facebook and other big giants have created these framework with lots of effort and research so yes we can use it any framework of our choice.

Examples

  1. React.js
  2. Angular.js
  3. Vue.js
  4. Ember.js
  5. Meteor.js

So, if you are a new start in the Javascript and want to deep dive with any of the framework or you have picked randomly any and want to know the best one to learn, then yes you are at the right place. Although choosing a right framework of for your app totally depends on the need and architecture of your app, and completely a topic of debate, however we can provide you the pros and cons of the framework and let you decide.

React JS

More a JS library than framework, React JS is opens sourced by Facebook in 2013. In early years React was not so popular due to it’s difficult learning curve and easy adoption of AngularJS(1) but later on with the increasing issues of two way binding and digest cycle developers started to looking for other possible options and React has come out a viable choice for them

Pros of React Js
  1. Uses virtual DOM, hence DOM re rendering and unnecessary manipulation is saved
  2. With the use of Babel Transpiler, it is easy to use ES6 and ES7 code with React
  3. Absolutely light-weighted
  4. JSX rather than HTML- Since react uses everything in JS, you could create your own views and components and can leverage the power of full programming languages
  5. While creating a large application state management is a necessary part of your app while communicating among different pages, with the help of state management solutions like redux, flux it easy to integrate with React
  6. Fast runtime performance using component lifecycle methods
Cons of React Js
  1. Difficult learning curve
  2. Since HTML and css both are in JSX, so need a developer rather than designed for simple page design of HTMl code

Vue JS

Earlier started in 2013 Vue JS was very much similar to AngularJS but later on with the shortcomings in Angular 1 Vue community started optimizing the Vue code and finally they come up with Vue2.0 in 2016 pulling all best things from Ember, React and Angular, hence proved to be faster than any other framework.

Pros of Vue Js
  1. Adaptability: Similarity in terms of design and architecture with both Angular and React it is easy to adapt a developer coming from any framework
  2. With the use of Babel Transpiler, it is easy to use ES6 and ES7 code with React
  3. Optimization Efforts: Performance of Vue apps is comparable to React since the developers of Vue has maintained it.
  4. JSX rather than HTML- Since react uses everything in JS, you could create your own views and components and can leverage the power of full programming languages
  5. State management cn be done using Redux or step further Vuex
  6. Light weighted and cross platform support
  7. No need of any webpack or any other compiler for a small applications
Cons of Vue Js
  1. Lack of resources: Compared to React and Angular the community network of Vue JS is small, hence no knowledge share
  2. Due to lack of community support it is still in it’s beginning phase of development

Angularjs

Founded in 2009, Angular reamined on of the best choice for developers due to it’s easy adaptability and learning curve but later on Google release further versions of Angularjs and now with version 2 and higher it is comparable to other framework as well

  1. GLobal community support: Whatever you say the community support of Angularjs is still the largest compared to React or Vue JS
  2. Full-fledged framework where you would have ready made tools for your needs.
  3. Two way data binding helps in data sync in view and model
  4. Typescript is an enhanced set of JS which can overcome all the shortcomings of JS like static type checking, immutability etc.
  5. Now with Angular 2 and higher the architecture is purely component based
Cons of Angular Js
  1. The complex syntax of Typescript has made less adaptable this language towards developers
  2. Frequent releases of Angular Versions it has difficult for developers and companies to migrate their code for the newer versions

Ember.js

Pros of Ember Js
  1. Template code is easy to write with Handlebars
  2. Since it is framework you need to focus on creating your app not on trivial things
Cons of Ember Js
  1. You need to be familiar with their conventions, hence required a lot of effort to learn them
  2. Less flexible compared to other framework
  3. Performance wise we could have better options like React and VueJS

Meteor.js

A rapid software development option with both backend and front end using Javascript Meteor is a nice choice for a full stack developer

Pros of Meteor Js
  1. Makes web development easier, flexible and requires less code
  2. Development with just one language, no need for MERN or MEAN stack
  3. Real time applications i.e. all of the application’s layer from database to template update automatically, so no need of page refresh.
  4. Smart packages like user accounts, bootstrap stylus.
  5. Make your web app an Android and Ios app with meteor only
 

Useful editors for programmers

Text editor is a program that help to edit text

Sublime Text

Sublime Text is a fast and sophisticated text editor.This editor is highly extensible with large plugin/package support.There are various packages available that help to extend it’s functionality.

Features:

  • Go to definition
  • Cross platform
  • Split screens
  • Lightweight
  • Highly extendable

Download Sublime

Atom

Atom is a free, open source editor that can be used on windows, Linux and mac system.  Atom is developed by GitHub. There are thousands of packages and themes that help to improve it’s functionality.

Features:

  • Cross Platform
  • Built in package manager
  • File system browse
  • Syntax autocomplete
  • Rich UI

Download Atom

Brackets

Brackets is a modern, open source, lightweight and fast editor that is written in HTML, css and js.

Features:

  • Lightweight
  • Inline Editing
  • Run time preview
  • Cross platform

Downlaod Brackets

Notepad++

Notepad++ is a free, award wining source code editor that is used for windows.Notepad++ is written in C++. It supports macros.

Features:

  • Autocomplete
  • Syntax highlighting
  • Auto-save feature
  • Split screens
  • Code folding

Download Notepad++

Komodo

Komodo is a robust free text editor used for programming languages.

Features:

  • Autocomplete
  • Minimap
  • Multi language Edit
  • Unit testing
  • Live Preview

Download Komodo

Aptana Studio

Aptana Studio is a most powerful open source IDE used for web applications. It is based on eclipse.

Features:

  • Large JS library supoort
  • Inbuilt Debugger
  • Command line access
  • Ftp/Sftp support

Download Aptana