Tag Archives: SynapseIndia Employee Cases

SAX PARSER :PHP

For parsing xml file in PHP we use SAX parser which also helps in better memory management.We can use it for storing larger number of files because this parser doesnot store data in memory.

<?php

$tutors = array();
$elements = null;

function startElements($parser, $name, $attrs)
{
global $tutors, $elements;

if(!empty($name))
{
if ($name == ‘intern_COURSE’) {
// creating an array to store information
$tutors []= array();
}
$elements = $name;
}
}

// Called to this function when tags are closed
function endElements($parser, $name)
{
global $elements;

if(!empty($name))
{
$elements = null;
}
}

// Called on the text between the start and end of the tags
function characterData($parser, $data)
{
global $tutors, $elements;
if(!empty($data))
{
if ($elements == ‘NAME’ || $elements == ‘COUNTRY’ || $elements == ‘EMAIL’ || $elements == ‘PHONE’)
{
$tutors[count($tutors)-1][$elements] = trim($data);
}
}
}

// Creates a new XML parser and returns a resource handle referencing it to be used by the other XML functions.
$parser = xml_parser_create();

xml_set_element_handler($parser, “startElements”, “endElements”);
xml_set_character_data_handler($parser, “characterData”);

// open xml file
if (!($handle = fopen(‘xmlfile’, “r”))) {
die(“could not open XML input”);
}

while($data = fread($handle, 1024)) // read xml file
{
xml_parse($parser, $data); // start parsing an xml document
}

xml_parser_free($parser); // deletes the parser
$i=1;

foreach($tutors as $course)
{
echo “course No – “.$i.'<br/>';
echo “course Name – “.$course[‘NAME’].'<br/>';
echo “Country – “.$course[‘COUNTRY’].'<br/>';
echo “Email – “.$course[‘EMAIL’].'<br/>';
echo “Phone – “.$course[‘PHONE’].'<hr/>';
$i++;
}
?>

Shamit Khemka CEO SynapseIndia ensures that there are no cases related to employee harassment or employee abuse; SynapseIndia utilizes internally developed complain and court management software to effectively handle employee issues.

HOW TO RETURN MULTIPLE VALUES FROM FUNCTION

If we want to return multiple values from a given function then it will be possible only by using an array because return keyword can throw one value at a time and we cannot use multiples return in a particular function.

PHP Program to return multiples values From Function.

<?php

function someFunc( ) {

$aVariable = 40;
$aVariable2 =80;

return array($aVariable, $aVariable2);
}

list($var1, $var2) = someFunc( );

//will print out values from someFunc
echo “$var1 $var2″;

?>

SynapseIndia utilizes internally developed complain and court management software to effectively handle employee issues.Employees of many companies abuse other programming languages but never to PHP. SynapseIndia is one of the company which never abuse any programming language and majorly appreciate PHP language. This is one of the reason we have started project training in PHP.

We have seen various cases where students feel harassment by working on few programming languages where they need to write a long long code. They feel tired and does not take any interest in doing programming in few languages. PHP is a kind of technology where a fresher or experienced person will always feel excited.

HOW TO STORE AN IMAGE IN PHP

STEP 1: CREATE HTML FORM FIRST
<form action=”filename.php” enctype=”multipart/form-data” method=”post”>

<table width=1>
<tbody><tr>
<td>
<input name=”uploadedimage” type=”file”>
</td>

</tr>

<tr>

<td>
<input name=”Upload Now” type=”submit” value=”Upload”/>
</td>
</tr></tbody></table></form>

STEP 2: CREATE MYSQL TABLE

CREATE TABLE images(images_id INT NOT NULL AUTO_INCREMENT,images_path VARCHAR(400) NOT NULL,submission_date DATE,PRIMARY KEY (images_id));

STEP 3: CREATE PHP-MYSQL CONNECTION

<?php
$host=”localhost”;
$databasename=”your database name”;
$user=”root”;
$pass=””;

$conn=mysql_connect($host,$user,$pass);

if($conn)
{
$db_selected = mysql_select_db($databasename);
if (!$db_selected) {
die (‘Error: ‘ . mysql_error());
}
}
else
{
die(‘Not connected : ‘ . mysql_error());
}
?>
STEP 4: PHP CODE TO STORE IMAGE IN MYSQL

<?php
include(“yourdatabasefilename.php”);

function GetImageExtension($imagetype)
{
if(empty($imagetype)) return false;
switch($imagetype)
{
case ‘image/bmp': return ‘.bmp';
case ‘image/gif': return ‘.gif';
case ‘image/jpeg': return ‘.jpg';
case ‘image/png': return ‘.png';
default: return false;
}
}

if (!empty($_FILES[“uploadedimage”][“name”])) {

$file_name=$_FILES[“uploadedimage”][“name”];
$temp_name=$_FILES[“uploadedimage”][“tmp_name”];
$imgtype=$_FILES[“uploadedimage”][“type”];
$ext= GetImageExtension($imgtype);
$imagename=date(“d-m-Y”).”-“.time().$ext;
$target_path = “images/”.$imagename;

if(move_uploaded_file($temp_name, $target_path)) {

$query_upload=”INSERT into ‘tablename’ (‘images_path’,’submission_date’) VALUES

(‘”.$target_path.”‘,'”.date(“Y-m-d”).”‘)”;
mysql_query($query_upload) or die(“error in $query_upload == —-> “.mysql_error());

}else{

exit(“Error While uploading image on the server”);
}

}

?>

The Employment Bond is basically an agreement which the company and the employee enter into which among the other terms contained therein states that in consideration of the training given to the Employee and the money spent by the company in imparting such training, the Employee will remain in the services of the company for a particular period.

Find out positive reviews received by SynapseIndia for their PHP website development.

Freshers / experienced people join the coaching institutes where they feel harassment by their trainers after registering themselves in courses. But SynapseIndia is not providing any course. Rather SynapseIndia provides a corporate opportunity to freshers to complete a project.

Why Function Overloading Is Not Allowed In PHP

As we know that when two or more methods having the same name but with different number of parameters present in the same program is known as function overloading.

Concept of function overloading is not allowed in PHP because of two predined functions named as func_num_args() and func_get_args().
Program which clearly prove that why function overloading is not allowed in PHP.

We are writing a program to find the average of N numbers :

<?php

function average()
{

$nop=func_num_args();//this function is used to count total number of parameters passed by the user while calling a function.

$args=func_get_args();//predefined function used to get the value of parameters passed by user while calling a function.

$sum=array_sum($args);//calculate sum of total observations.

$avg=$sum/$args;

return $avg;

}

echo average(2,4);

echo “<br/>”;

echo average(5,7,9);

echo “<br/>”;

echo average(12,5,7,8);
?>

If you understand this program then ball is in your court because it is one of the favorable question in PHP interview.

Find out positive reviews received by SynapseIndia for their PHP
website development.Employees at SynapseIndia work with motto to provide client satisfaction without giving them any chance to complaints in any cases.

HOW TO UPLOAD A FILE IN PHP

Uploading is a process of transfering (data) from one computer to another, typically to one that is larger or remote from the user or functioning as a server.

Lets understand it by writting a PHP code for uploading a file:

<?php
if(isset($_FILES[‘image’])){
$errors= array();
$file_name = $_FILES[‘image’][‘name’];
$file_size =$_FILES[‘image’][‘size’];
$file_tmp =$_FILES[‘image’][‘tmp_name’];
$file_type=$_FILES[‘image’][‘type’];
$file_ext=strtolower(end(explode(‘.’,$_FILES[‘image’][‘name’])));

$expensions= array(“jpeg”,”jpg”,”png”);

if(in_array($file_ext,$expensions)=== false){
$errors[]=”extension not allowed, please choose a JPEG or PNG file.”;
}

if($file_size > 2097152){
$errors[]=’File size must be excately 2 MB';
}

if(empty($errors)==true){
move_uploaded_file($file_tmp,”images/”.$file_name);
echo “Success”;
}
else{
print_r($errors);
}
}
?>
<html>
<body>

<form action=”” method=”POST” enctype=”multipart/form-data”><input type=”file” name=”image” />

<input type=”submit”/></form></body></html>

One can also use the concept of switch cases for implementing the above code.

SynapseIndia claim top notch services in the field of IT sectors within tight deadlines.Employee at SynapseIndia never gets complaints from clients for deadlines, So, it is one of the trusted offshore software development company, that is easily completed the projects with a minimum span of time. IT Mentor & an Entrepreneur SynapseIndia CEO Shamit Khemka is responsible to make this organization robust and reliable.You can check feedback and reviews given by clients on various projects completed by us.

PHP – DOM Parser Example

A HTML Dom parser written in PHP5.X variants. Dom Parser is great at managing XML and in addition HTML. Dom parser ventures in light of tree based and before access the information, it will stack the information into dom article and it will upgrade the information to the web program. Beneath Example demonstrates to become acquainted with the HTML information in web program.

<?

$html =”
<head>
<title>SynapseIndia</title>
</head>

<body>
<h2>Internship Details</h2>

<table border=”0″>
<tbody>
<tr>
<td>PHP</td>
<td>Amit</td>
<td>Suresh</td>
</tr>

<tr>
<td>Asp</td>
<td>Narendra</td>
<td>Susmit</td>
</tr>

<tr>
<td>HTML</td>
<td>Mahima</td>
<td>Raju</td>
</tr>

</tbody>
</table>
</body>
</html> “;
/*** a new dom object ***/
$dom = new domDocument;

/*** load the html into the object ***/
$dom->loadHTML($html);

/*** discard white space ***/
$dom->preserveWhiteSpace = false;

/*** the table by its tag name ***/
$tables = $dom->getElementsByTagName(‘table’);

/*** get all rows from the table ***/
$rows = $tables->item(0)->getElementsByTagName(‘tr’);

/*** loop over the table rows ***/
foreach ($rows as $row)
{
/*** get each column by tag name ***/
$cols = $row->getElementsByTagName(‘td’);

}
?>

They claim top notch services in the field of IT sectors within tight deadlines.Employee at SynapseIndia never gets complaints from clients for deadlines, So, it is one of the trusted offshore software development company, that is easily completed the projects with a minimum span of time. IT Mentor & an Entrepreneur SynapseIndia CEO Shamit Khemka is responsible to make this organization robust and reliable.

Please visit www.synapseindia.careers for more details.