Object Oriented Programming (OOP) in PHP





We know that PHP is the one of the popular programming language basically used for dynamic webpage creation and web based application creation. PHP had released Object Oriented feature from it’s version 4. We cover it’s some of the most importance feature which are give below. But  you most have basic knowledge of PHP programming before learn these topics.

  • Why use OOP ?
  1. OOP allow us to groping similar function and variable together.
  2. OOP allow us to reuse code in efficient way.
  3. OOP allow us to write secure code.
  4. OOP allow us to reduce code and complexity of large project.
  5. OOP allow us to write code in more independent way.

what is Class ?
class defined the structure/ template/ bluprint of the problem. For example house map describe the structure or bluprint of behavior of the house.
What is Object ?
Object is instance of the class. For example in the house developmet proccess all required object like door, windows, brick, wood on the basic of desinged map of house.

Relation of Object and Class :
Class and object are co-related to each other. Class create the structure of the problem and object full fill the structure by providing request or data. Object are created for class to full fill the structure of class.

Posted in PHP

Codeigniter





It is an open source web application framework that helps you write incredible programs. It is MVC (Model-View-Controller) pattern framework. It Implements the object oriented concept. Codeigniter is easiest framework to understand MVC concept. If you want to develop web software, Codeigniter is the famous and easiest framework to work with. If you are willing to develop any project and you have not heared  before about Codeigniter framework then, this blog helps and makes you familiar to Codeigniter.

You can download the Codeigniter from its official site  https://www.codeigniter.com  as a zipped file.

Application Flow Chart:

1

The index.php serves as the default controller, initializing the basic resources needed to run Codeigniter.

The Controller loads the model, libraries, helpers, and any other resources needed to process the specific request.

The finalized View is rendered in the web browser to be seen.

 

Codeigniter folder structure is:

1) Application

2) Assets

3) User guide

4) System

5) Index.php

6) License.txt

7) .gitignore

8) .travis.yml

We need to work mostly in Application folder. In application folder, We have to make certain changes and work with the following folders.

1) Config

2) Controller

3)  Model

4) View

 

Now let’s introduce about model, view, controller and config folder.

View:

The View is the information that is being presented to a user. In this folder, we create a new file and html code is written. We can access it through controller only.

 

Controller:

It is the mediator to access both models and views and any other resources. In this folder we create a new PHP file and it controls the model and view part. Logical part of the project is written in this file.

Model:

The Model represents your data structures. Typically your model classes will contain functions that help you to perform database operations (INSERT, DELETE and UPDATE).

Config:

In Config we need two file database and config.

Database file is for the connection to the database and the config file for the configuration.

Now let’s do one demo project for the better understanding of Codeigniter framework.

 

First of all, unzip the downloaded folder, and place it inside htdocs folder which is in xampp folder and give name for your project.

When you run the project then this type of screen is shown

2

You can access the page by typing localhost/ProjectName.  My project name is zip, so my URL is localhost/zip to access the page.

 

Now make a new controller inside controller folder and name it as homepage.php

 

<?php

class Home extends CI_Controller{


// this is index url when you call this function in url this function is  loaded automatically


public function index(){


$this->load->view('home.php');


}

}

 

(You can access the home.php file of view folder by the URL localhost/homepage ; Remember the view cannot be loaded automatically from the URL. You need to access it from controller as mentioned above)

 

Now create a new home.php file inside views folder

<!DOCTYPE html>

<html>

<head>

<title></title>

</head>

<body>

<h1>Welcome to Home page</h1>

</body>

</html>

 

 

 

Then if you run the project with url localhost/zip/index.php/home then you can see in your browser

3

This welcome to home page message is written in home.php file inside views folder .
Now remove this index.php from your url we need to add new file name .htaccess and write this code inside this folder

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Then you need to changes in config file

You find there
$config[‘index_page’]=”index.php”;
Then you need to remove this index.php from $config[‘index_page’]=””;
And save this file

Then you run your project in browser you can see in browser

4

Posted in PHP

Complete List of Toolbar Items for CKEditor





Here are the complete list of toolbar items for CKEditor

                                Complete List of Toolbar Items for CKEditor
items
“Source”
“Save”
“NewPage”
“DocProps”
“Preview”
“Print”
“Templates”
“document”
items
“Cut”
“Copy”
“Paste”
“PasteText”
“PasteFromWord”
“Undo”
“Redo”
items
“Find”
“Replace”
“SelectAll”
“Scayt”
items
“Form”
“Checkbox”
“Radio”
“TextField”
“Textarea”
“Select”
“Button”
“ImageButton”
“HiddenField”
items
“Bold”
“Italic”
“Underline”
“Strike”
“Subscript”
“Superscript”
“RemoveFormat”
items
“NumberedList”
“BulletedList”
“Outdent”
“Indent”
“Blockquote”
“CreateDiv”
“JustifyLeft”
“JustifyCenter”
“JustifyRight”
“JustifyBlock”
“BidiLtr”
“BidiRtl”
items
“Link”
“Unlink”
“Anchor”
items
“CreatePlaceholder”
“Image”
“Flash”
“Table”
“HorizontalRule”
“Smiley”
“SpecialChar”
“PageBreak”
“Iframe”
“InsertPre”
items
“Styles”
“Format”
“Font”
“FontSize”
items
“TextColor”
“BGColor”
items
“UIColor”
“Maximize”
“ShowBlocks”
items
“button1”
“button2”
“button3”
“oembed”
“MediaEmbed”
items
“About”
Posted in PHP

Adding CKEditor in Codeigniter





I use this steps to add ckeditor to my codeigniter apps:

1) Download these files:

2) Copy the files you just downloaded into your Application/libraries folder

3) Download the ckeditor helper here: http://pastebin.com/Cd3GqYbx

4) Copy the last file in application/helper folder as ckeditor_helper.php

5) Download the CKeditor controller here: http://pastebin.com/UD0bB9ig

6) Copy the controller in your application/controllers folder as ckeditor.php

7) Download the main ckeditor project from the official site: http://ckeditor.com/download/

8) Copy the ckeditor folder you just download into your asset folder (if you want you can also download the ckfinder project and put it in the same folder)

9) Add these line of js to your view file (adjust the path):

<script type="text/javascript" src="/asset/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/asset/ckfinder/ckfinder.js"></script>

10) In your controller add this php code and adjust the path:

$this->load->library('ckeditor');
$this->load->library('ckfinder');



$this->ckeditor->basePath = base_url().'asset/ckeditor/';
$this->ckeditor->config['toolbar'] = array(
                array( 'Source', '-', 'Bold', 'Italic', 'Underline', '-','Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo','-','NumberedList','BulletedList' )
                                                    );
$this->ckeditor->config['language'] = 'it';
$this->ckeditor->config['width'] = '730px';
$this->ckeditor->config['height'] = '300px';            

//Add Ckfinder to Ckeditor
$this->ckfinder->SetupCKEditor($this->ckeditor,'../../asset/ckfinder/'); 

11) In your view print the editor with:

echo $this->ckeditor->editor("textarea name","default textarea value");
Posted in PHP

About PHP





Introduction To Php

PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.”

This is generally a good definition of PHP. However, it does contain a lot of terms you may not be used to. Another way to think of PHP is a powerful, behind the scenes scripting language that your visitors won’t see!

When someone visits your PHP webpage, your web server processes the PHP code. It then sees which parts it needs to show to visitors(content and pictures) and hides the other stuff(file operations, math calculations, etc.) then translates your PHP into HTML. After the translation into HTML, it sends the webpage to your visitor’s web browser.

PHP – What’s it do?
It is also helpful to think of PHP in terms of what it can do for you. PHP will allow you to:

Reduce the time to create large websites.
Create a customized user experience for visitors based on information that you have gathered from them.
Open up thousands of possibilities for online tools. Check out PHP – HotScripts for examples of the great things that are possible with PHP.
Allow creation of shopping carts for e-commerce websites.
What You Should Know
Before starting this tutorial it is important that you have a basic understanding and experience in the following:

HTML – Know the syntax and especially HTML Forms.
Basic programming knowledge – This isn’t required, but if you have any traditional programming experience it will make learning PHP a great deal easier.

Posted in PHP
Copyright © 2016 InfoxIT Portal. All rights reserved.
Seo wordpress plugin by www.seowizard.org.
Scroll To Top
Visit Us On FacebookVisit Us On Google PlusVisit Us On YoutubeCheck Our Feed