Print star pattern in PHP

Pattern 1

1 2
1 2 3
1 2 3 4
1 2 3 4 5

Pattern 2

2 2
3 3 3
4 4 4 4
5 5 5 5 5

Pattern 3

* *
* * *
* * * *
* * * * *

Pattern 4


* *
* * *
* * * *
* * * * *

Secondary site setting :

SET UP A New Site(John project)

1) Create domain id for the site.

steps to Create a new domain:

1. create a new domain in appolo – (if its a secondary site means give domain group as secondary site).
2. Create a GAPI keys for the created domain –
3. Map new domain with GAPI and other API’s –
4. Edit the “Set Domain Credentials” icon from the domain api list for the new domain.
Keys can be get from the Step2 and add the GAPI urls for live, stage and dev.
5.Map the other apis used for the site using domain api mapping

email setup:
need to configure emails in following tables.
note: this is not need for secondarysites coz mail send via tourbeaver.

2) create a secondary site.

there are 3 checkouts available in SecondarySites,
1. austin checkout
2. alcatrazticket checkout
3. devdbtesttemp checkout

1 create the website using tb_websites menu in venus. this is saved in tb_websites.

note: city name and state code should be mapped with tb_priceline_city table.

2. get the website id in tb_website and manually add the tb_website_id in domain table .

Reduce site loading time – mod_deflate :

Add the below code to .htaccess file to compress the output of the site then the site performance will be better.

<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml

# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

Setting default permissions for newly created files and sub-directories in Linux :

chmod g+s <directory>  //set gid 
setfacl -d -m g::rwx /<directory>  //set group to rwx default 
setfacl -d -m o::rx /<directory>   //set other

Next we can verify:

getfacl /<directory>


# file: ../<directory>/
# owner: <user>
# group: media
# flags: -s-
Difference between php4 and php5 PHP5 introduces many new features, I have mentioned some of them:Unified Constructors and Destructors:
In PHP4, constructors had same name as the class name where In PHP5, you simply need to name your constructors as __construct()
In PHP5 you can declare a class as Abstract.Startic Methods and properties:
Static methods and properties are also available. When you declare a class member as static, then you can access members using :: operator without  creating an instance of class.

PHP5 introduces a special function called __autoload()Final:
PHP5 allows you to declare a class or method as Final Magic Methods
PHP5 introduces a number of magic methods.
__call, __get, __set and __toString————————————————————————————————————————————————————–

PHP Server variables :


PHP : $_SERVER[‘argv’]

PHP : Super global variable: $argc





















– See more at:$_SERVER.php#sthash.hKXsezPK.dpuf


To change the date format :

$payment_date = date(‘Y-m-d H:i:s’,strtotime($_POST[‘payment_date’]));
Dubai Time Zone :
Example : 1
print date(“F d, Y H:i:s”, time())
Example : 2
$timezone = “Asia/Dubai”;
if(function_exists(‘date_default_timezone_set’)) date_default_timezone_set($timezone);
Live server configuration :
This program makes use of the Zend Scripting Language Engine:
  • Linux Server (Apache)
  • PHP Version 5.2.17
  • Mysql Version 5.5.23
  • PHPmyadmin version
  • Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
  • With the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd., and
  • With Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
  • IonCube Loader Enabled
  • GD Library needs to be installed
  • option to edit php.ini file
  • mod_rewrite Enabled
  • mime_magic.debug – OFF
  • Session Support – Enabled

Java script Validation :

function team_regform()
var Errmsg = true;

if(document.getElementById(“logo”).value == “”)
document.getElementById(“err_logo”).style.display = “block”;
document.getElementById(“err_logo”).innerHTML = “Logo field is required”;
Errmsg = false;

if(document.getElementById(“logo”).value != “”)
var fup = document.getElementById(‘logo’);
var fileName = fup.value;
var ext = fileName.substring(fileName.lastIndexOf(‘.’) + 1);
if(ext == “gif” || ext == “GIF” || ext == “JPEG” || ext == “jpeg” || ext == “jpg” || ext == “JPG” || ext == “png”)
Errmsg = true;
document.getElementById(“err_logo”).innerHTML = “Invalid logo format”;
Errmsg = false;


var checkString = document.getElementById(“phone”).value;
if (checkString != “”)
document.getElementById(“err_phone”).style.display = “block”;
document.getElementById(‘err_phone’).innerHTML = “Please enter valid contact number”;
Errmsg = false;


if(document.getElementById(’email’).value != “”)

var email_id = document.getElementById(’email’);
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email_id.value))
document.getElementById(“err_email”).style.display = “block”;
document.getElementById(‘err_email’).innerHTML = “Please enter valid email”;
Errmsg = false;


if(Errmsg == false)
return false;
return true;

function empty(id)
document.getElementById(id).innerHTML = “”;
return true;


SEO Friendly URL : (Linscan/.htaccess)

Options +FollowSymLinks
RewriteEngine on
RewriteRule index-(.*)-(.*)\.html$ index.php?id=$1&lang=$2
RewriteRule index-(.*)\.html$ index.php?logo=$1
RewriteRule career-(.*)-(.*)\.html$ career.php?id=$1&lang=$2
RewriteRule sitemap-(.*)-(.*)\.html$ sitemap.php?id=$1&lang=$2
RewriteRule sitemap-(.*)\.html$ sitemap.php?id=$1
RewriteRule enquiry-(.*).html$ enquiry.php?id=$1
RewriteRule feedback-(.*)\.html$ feedback.php?id=$1
RewriteRule vision-mission-(.*)-id-(.*)\.html$ vision_mission.php?sno=$1&id=$2
RewriteRule aboutus-(.*)\.html$ who_we_are.php?id=$1
RewriteRule location-map-(.*)\.html$ location_map.php?id=$1
RewriteRule disclaimer-(.*)\.html$ disclaimer.php?id=$1
RewriteRule privacy-policy-(.*)\.html$ privacy_policy.php?id=$1
RewriteRule help-(.*)\.html$ help.php?id=$1
RewriteRule contest-(.*)\.html$ contest_form.php?id=$1
RewriteRule search-(.*)\.html$ search.php?lang=$1
RewriteRule result-(.*)-(.*)\.html$ search_result.php?id=$1&lang=$2
RewriteRule location-map-(.*)\.html$ location_map.php?id=$1
RewriteRule vision-mission-(.*)-(.*)\.html$ vision_mission.php?sno=$1&id=$2
RewriteRule news-press-release-(.*)-(.*)\.html$ news_press_release.php?sid=$1&id=$2
RewriteRule news-press-viewall-(.*)\.html$ news_press_viewall.php?id=$1
RewriteRule (.*)-(.*)-(.*)\.html$ submenu.php?name=$1&id=$2&lang=$3

Virtual Host Creation :

virtual host for each project in our local and set a separate environment for that virtual host, so that it doesn’t have to conflict with the localhost environment which John (and the team at his end) may also be using.

For example, for devehappy, see the main index.php, I have set up a separate environment “vivid_local” for the (virtual) host “devehappy.vivid” .
So the config folder for this environment is config/vivid_local

So here are the steps to set up a virtual host in your local;

1) In C:\Windows\System32\drivers\etc\hosts file
add this localhost (Don’t add this line if it already exists) devehappy.vivid

2) In your xampp\apache\conf\extra\httpd-vhosts.conf  file (for wamp this path may be a little different)
add this
NameVirtualHost *:80 (Don’t add this line if it already exists)
<VirtualHost *:80>
DocumentRoot “D:/xampp/htdocs/devehappy”
ServerName devehappy.vivid

3) Restart apache

Now you should be able to access the site with http://devehappy.vivid

What will the different functions return?

All of the mentioned functions will return an array, the differences between them is what values that are being used as keys in the returned object.

  • mysql_fetch_rowThis function will return a row where the values will come in the order as they are defined in the SQL query, and the keys will span from 0 to one less than the number of columns selected.
  • mysql_fetch_assocThis function will return a row as an associative array where the column names will be the keys storing corresponding value.
  • mysql_fetch_arrayThis function will actually return an array with both the contents of mysql_fetch_rowand mysql_fetch_assoc merged into one. It will both have numeric and string keys which will let you access your data in whatever way you’d find easiest.It is recommended to use either _assoc or _row though.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s