Wednesday, 28 November 2012

What is the difference between $message and $$message?

What is the difference between $message and $$message?


They are both variables. But $message is a variable with a fixed name.
$$message is a variable who‘s name is stored in $message.

 For example
 if $message contains ―var1, $$message is the same as $var.

Detailed Code :

<?php
//Dear Techies this Script has one simple variable ie
$car_name = 'Ford';
//now  assign variable $car_name to $get_car_name
$get_car_name = $car_name;
echo $get_car_name.'<br>';
//answer is : Ford;

//this is simple variable..
//we can get the same answer in different technique..this can be done by
//using reference variable or variable of variable or using $$ dollar sign
//check this

$get_car_name_using_ref_var = 'car_name';

echo $$get_car_name_using_ref_var;
?>

I think now you can understand the difference between variable and reference variable in PHP

if u like this post, please put your valuable comments..

Upload File Using FTP

  Upload Single file using FTP in PHP.


// FTP access parameters
$host = 'ftp.example.org';
$usr = 'example_user';
$pwd = 'example_password';
 
// file to move:
$local_file = './example.txt';
$ftp_path = '/data/example.txt';
 
// connect to FTP server (port 21)
$conn_id = ftp_connect($host, 21) 
or die ("Cannot connect to host");
 
// send access parameters
ftp_login($conn_id, $usr, $pwd) or die("Cannot login");
 
// turn on passive mode transfers (some servers need this)
// ftp_pasv ($conn_id, true);
 
// perform file upload
$upload = ftp_put($conn_id, $ftp_path, $local_file,
 FTP_ASCII);
 
// check upload status:
print (!$upload) ? 'Cannot upload' : 'Upload complete';
print "\n";
 
/*
** Chmod the file (just as example)
*/
 
// If you are using PHP4 then you need to use this code:
// (because the "ftp_chmod" command is just available 
in PHP5+)
if (!function_exists('ftp_chmod')) {
   function ftp_chmod($ftp_stream, $mode, $filename){
        return ftp_site($ftp_stream, sprintf('CHMOD %o %s',
 $mode, $filename));
   }
}
 
// try to chmod the new file to 666 (writeable)
if (ftp_chmod($conn_id, 0666, $ftp_path) !== false) {
    print $ftp_path . " chmoded successfully to 666\n";
} else {
    print "could not chmod $file\n";
}
 
// close the FTP stream
ftp_close($conn_id);

Regular Expressions Concept In PHP Part 1


What is regular expression ?

Regular expression originating from the Unix system . where a program was designed , called grep. To help the developers to work on string and manipulate the strings.

Regular expression is search for a pattern in a given string or text. these search pattern written using a special format which a regular expression parser understand.

Regular expression is a very useful tool for developers, they allow to find , identify or replace text, word or any kind of character.

Regular expression is also called REGEX or REGEXP.

Regular expression syntax

Regular Expression                 Will match
1)     Foo                               this is a string, the string “foo”
2)      ^foo                             “foo”  at the start of a string
3)      Foo$                             “foo” at he end of a string  
4)      ^foo$                           “foo” when it is alone on a string
5)      [abc]                              a,b, or c
6)      [a-z]                               any lower case leter
7)      [^A-Z]                           any character that is not uppercase letter
8)      (gif|jpeg)                        matches either gif or jpeg  
9)      [a-z]+                            one or more lowercase letters        
10)   [0-9.-]                           any numbers, dot or minus sign      
11)   ^[a-zA-Z0-9_]{1,}$       any word of at least 1 letter, number or underscore
12)    ([wx])([yz])                  wy, wz, xy, or xz    
13)   [^a-zA-Z0-9]                any symbols but not any letter or number  
14)   ([A-Z]{3}|[0-9]{4})       Matches three letters or four numbers
a
    Dont Forget to leave Your comments...
 
    Part 2 will coming soon.....


Tuesday, 20 November 2012

Language of the year

Before Entering to the programming world, we should know the index of programming language. As like Business ,there is a competition between all programming languages. The following link that i am providing will guide the developers to check whether their  programming skills are still up to date or to make a strategic decision about what programming language should be adopted when starting to build a new software system

Blog ranking statistics                              

  TIOBE Programming Community Index for November 2012

                         Source : http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

Position
Nov
2012
Position
Nov
 2011
Delta
in
Position
Programming
Language
Ratings
Nov
2012
Delta
Nov
 2011
Status
1 2 C 9.224% +1.90%   A
2 1 Java 17.455% -0.42%   A
3 6 Objective-C 10.383% +4.40%   A
4 3 C++ 9.698% +1.61%   A
5 5 PHP 5.732% -0.36%   A
6 4 C# 5.591% -1.73%   A
7 7 (Visual) Basic 5.032% -0.01%   A
8 8 Python 4.062% +0.45%   A
9 10 Perl 2.182% +0.10%   A
10 11 Ruby 1.739% +0.24%   A
11 9 JavaScript 1.278% -1.29%   A
12 16 Delphi/
Object Pascal
0.995% +0.12%   A
13 13 Lisp 0.951% -0.23%   A
14 14 Pascal 0.881% -0.11%   A
15 23 Visual Basic
 .NET
0.769% +0.24%   A-
16 19 Ada 0.662% +0.04%   B
17 12 PL/SQL 0.632% -0.81%   B
18 18 Lua 0.631% 0.00%   A-
19 15 MATLAB 0.620% -0.34%   B
20 24 Assembly 0.585% +0.06%   B




Long term trends

The long term trends for the top 10 programming languages can be found in the line diagram below.



Hello Techies

Hello Techies, I ll get back on this blog very soooon with new ideas till then any addition or contribution would be a welcome. ........get in touch