Opensource

The term open source describes practices in production and development that promote access to the end product’s source materials.Before the term open source became widely adopted, developers and producers used a variety of phrases to describe the concept; open source gained hold with the rise of the Internet.

Open-source software (OSS) is computer software that is available in source code form: the source code and certain other rights normally reserved for copyright holders are provided under a software license that permits users to study, change, improve and at times also to distribute the software.

Why PHP

  • PHP is open source
  • PHP is free to download and use
  • PHP is compatible with platform like Linux ,Windows etc
  • PHP can be used with the servers like Apache,IIS etc .
  • PHP suports databses like Mysql,Oracle etc

PHP

PHP is a server side scripting language used in web development to cerate dynamic web pages and can be embedded into HTML codes .The web server with php processor module interprets the code and geneate the web pages as per the given code .

PHP is a loosely typed language. It means you do not have to tell PHP which data type the variable is.PHP automatically converts the variable to the correct data type, depending on its value.

PHP stands for PHP Hypertext Preprocessor (A recursive acronym) .Earlier it was known as personnel home pages .

PHP is an open source software and its free to download and use .

It supports many databases like MySql,Oracle etc…

DOM

The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents.[1] Aspects of the DOM (such as its “Elements”) may be addressed and manipulated within the syntax of the programming language in use. The public interface of a DOM is specified in its application programming interface (API).

Following are the valid DOM save methods

A. save()
B. saveXML()
C. saveHTML()
D. saveHTMLFile()

Send mail with attachment – PHP

<?php

class sendMail{

function send($mailto, $subject,$message , $filename, $path, $from_mail, $from_name, $replyto ) {

if(!empty($filename)) {
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, “r”);
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$name = basename($file);
}

$uid = md5(uniqid(time()));

$header = “From: “.$from_name.” <“.$from_mail.”>rn”;
$header .= “Reply-To: “.$replyto.”rn”;
$header .= “MIME-Version: 1.0rn”;
$header .= “Content-Type: multipart/mixed; boundary=””.$uid.””rnrn”;
$header .= “This is a multi-part message in MIME format.rn”;
$header .= “–“.$uid.”rn”;
$header .= “Content-type: text/html; charset=iso-8859-1n”;
$header .= “Content-Transfer-Encoding: 7bitrnrn”;
$header .= $message.”rnrn”;
$header .= “–“.$uid.”rn”;

if(!empty($filename)) {
$header .= “Content-Type: application/octet-stream; name=””.$filename.””rn”; // use different content types here
$header .= “Content-Transfer-Encoding: base64rn”;
$header .= “Content-Disposition: attachment; filename=””.$filename.””rnrn”;
$header .= $content.”rnrn”;
$header .= “–“.$uid.”–“;
}

if (mail($mailto, $subject, “”, $header)) {
return 1;
} else {
return 0;
}
}

}

 

$mail = new sendMail();

$mail->send(“info@phpcodez.com”,”Test”,”Test” , “image1.jpg”,”../images/”,”newsletter@phpcodez.com”,”PHPCodez”,”newsletter@phpcodez.com”);

?>

var_export

It prints parsable string representation of a variable

Example
======

<?php
echo “<pre>”;
$array = array(“php”,”codez”, array(“1”, “1”, “7”),1,2);
var_export($array);
?>

Output
=====
array (
0 => ‘php’,
1 => ‘codez’,
2 =>
array (
0 => ‘1’,
1 => ‘1’,
2 => ‘7’,
),
3 => 1,
4 => 2,
)

var_dump

It displays structured information about one or more expressions .

Example
======

<?php
echo “<pre>”;
$array = array(“php”,”codez”, array(“1”, “1”, “7”),1,2);
var_dump($array);
?>

Output
=====
array(5) {
[0]=>
string(3) “php”
[1]=>
string(5) “codez”
[2]=>
array(3) {
[0]=>
string(1) “1”
[1]=>
string(1) “1”
[2]=>
string(1) “7”
}
[3]=>
int(1)
[4]=>
int(2)
}