Base64 javascript 版

JavaScript代码
  1. <script language='javascript' src='Base642.js'></script>  
  2. <SCRIPT LANGUAGE="JavaScript">  
  3. <!--  
  4.     var b = new Base64();  
  5.     de = b.Decode64("aHR0cDovL3d3dy5pYnJpbmcuc2UvcGhwLnBocA==");  
  6.     alert(de);  
  7. //-->  
  8. </SCRIPT>  

 

Base642.js 见附件

Read More

PHP的输入过滤器

PHP代码
  1. $result = filter_input(INPUT_GET, ‘email’, FILTER_VALIDATE_EMAIL);  
  2. var_dump($result);  
  3. ?>  

简介

This extension serves for validating and filtering data coming usually from some insecure source such as user input.

该扩展用于检验和过滤来自不安全途径的数据,比如说用户的输入。

The following filters currently exist, be sure to read the Filter Constants section for information that describes the behavior of each constant:

下边这些过滤器是当前已经有的,请阅读过滤器常量小节查看各个常量的行为描述。

表 1. Existing filters

<table border="1" class="CALSTABLE">
  <colgroup> <col></col> <col></col> <col></col> <col></col> </colgroup> <tr>
    <th>
      ID
    </th>
    
    <th>
      Name
    </th>
    
    <th>
      Options
    </th>
    
    <th>
      Flags
    </th>
    
    <th>
      Description
    </th>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_VALIDATE_INT</strong></tt>
    </td>
    
    <td>
      "int"
    </td>
    
    <td>
      <code class="parameter">min_range</code>, <code class="parameter">max_range</code>
    </td>
    
    <td>
      <tt class="constant"><strong>FILTER_FLAG_ALLOW_OCTAL</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ALLOW_HEX</strong></tt>
    </td>
    
    <td>
      Validates value as integer, optionally from the specified range.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_VALIDATE_BOOLEAN</strong></tt>
    </td>
    
    <td>
      "boolean"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      Returns <tt class="constant"><strong>TRUE</strong></tt> for "1", "true", "on" and "yes", <tt class="constant"><strong>FALSE</strong></tt> for "0", "false", "off", "no", and "", <tt class="constant"><strong>NULL</strong></tt> otherwise.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_VALIDATE_FLOAT</strong></tt>
    </td>
    
    <td>
      "float"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      Validates value as float.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_VALIDATE_REGEXP</strong></tt>
    </td>
    
    <td>
      "validate_regexp"
    </td>
    
    <td>
      <code class="parameter">regexp</code>
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      Validates value against <code class="parameter">regexp</code>, a <a href="ref.pcre.html">Perl-compatible</a> regular expression.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_VALIDATE_URL</strong></tt>
    </td>
    
    <td>
      "validate_url"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      <tt class="constant"><strong>FILTER_FLAG_SCHEME_REQUIRED</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_HOST_REQUIRED</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_PATH_REQUIRED</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_QUERY_REQUIRED</strong></tt>
    </td>
    
    <td>
      Validates value as URL, optionally with required components.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_VALIDATE_EMAIL</strong></tt>
    </td>
    
    <td>
      "validate_email"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      Validates value as e-mail.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_VALIDATE_IP</strong></tt>
    </td>
    
    <td>
      "validate_ip"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      <tt class="constant"><strong>FILTER_FLAG_IPV4</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_IPV6</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_NO_PRIV_RANGE</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_NO_RES_RANGE</strong></tt>
    </td>
    
    <td>
      Validates value as IP address, optionally only IPv4 or IPv6 or not from private or reserved ranges.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_SANITIZE_STRING</strong></tt>
    </td>
    
    <td>
      "string"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      <tt class="constant"><strong>FILTER_FLAG_NO_ENCODE_QUOTES</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_STRIP_LOW</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_STRIP_HIGH</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ENCODE_LOW</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ENCODE_HIGH</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ENCODE_AMP</strong></tt>
    </td>
    
    <td>
      Strip tags, optionally strip or encode special characters.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_SANITIZE_STRIPPED</strong></tt>
    </td>
    
    <td>
      "stripped"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      Alias of "string" filter.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_SANITIZE_ENCODED</strong></tt>
    </td>
    
    <td>
      "encoded"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      <tt class="constant"><strong>FILTER_FLAG_STRIP_LOW</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_STRIP_HIGH</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ENCODE_LOW</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ENCODE_HIGH</strong></tt>
    </td>
    
    <td>
      URL-encode string, optionally strip or encode special characters.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_SANITIZE_SPECIAL_CHARS</strong></tt>
    </td>
    
    <td>
      "special_chars"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      <tt class="constant"><strong>FILTER_FLAG_STRIP_LOW</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_STRIP_HIGH</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ENCODE_HIGH</strong></tt>
    </td>
    
    <td>
      HTML-escape <tt class="literal">'"<>&</tt> and characters with ASCII value less than 32, optionally strip or encode other special characters.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_UNSAFE_RAW</strong></tt>
    </td>
    
    <td>
      "unsafe_raw"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      <tt class="constant"><strong>FILTER_FLAG_STRIP_LOW</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_STRIP_HIGH</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ENCODE_LOW</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ENCODE_HIGH</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ENCODE_AMP</strong></tt>
    </td>
    
    <td>
      Do nothing, optionally strip or encode special characters.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_SANITIZE_EMAIL</strong></tt>
    </td>
    
    <td>
      "email"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      Remove all characters except letters, digits and <tt class="literal">!#$%&'*+-/=?^_`{|}~@.[]</tt>.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_SANITIZE_URL</strong></tt>
    </td>
    
    <td>
      "url"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      Remove all characters except letters, digits and <tt class="literal">$-_.+!*'(),{}|\\^~[]`<>#%";/?:@&=</tt>.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_SANITIZE_NUMBER_INT</strong></tt>
    </td>
    
    <td>
      "number_int"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      Remove all characters except digits and <tt class="literal">+-</tt>.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_SANITIZE_NUMBER_FLOAT</strong></tt>
    </td>
    
    <td>
      "number_float"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      <tt class="constant"><strong>FILTER_FLAG_ALLOW_FRACTION</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ALLOW_THOUSAND</strong></tt>, <tt class="constant"><strong>FILTER_FLAG_ALLOW_SCIENTIFIC</strong></tt>
    </td>
    
    <td>
      Remove all characters except digits, <tt class="literal">+-</tt> and optionally <tt class="literal">.,eE</tt>.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_SANITIZE_MAGIC_QUOTES</strong></tt>
    </td>
    
    <td>
      "magic_quotes"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      Apply <a href="function.addslashes.html"><strong class="function">addslashes()</strong></a>.
    </td>
  </tr>
  
  <tr>
    <td>
      <tt class="constant"><strong>FILTER_CALLBACK</strong></tt>
    </td>
    
    <td>
      "callback"
    </td>
    
    <td>
      &nbsp;
    </td>
    
    <td>
      <a href="language.pseudo-types.html#language.types.callback"><strong class="type">callback</strong></a> function or method
    </td>
    
    <td>
      Call user-defined function to filter data.
    </td>
  </tr>
</table>

可以通过php.ini查看是否支持filter.

filter

  <td class="v">
    enabled
  </td>
</tr>

<tr>
  <td class="e">
    Revision
  </td>
  
  <td class="v">
    $Revision: 1.52.2.39 $
  </td>
</tr>
Input Validation and Filtering

  <th>
    Local Value
  </th>
  
  <th>
    Master Value
  </th>
</tr>

<tr>
  <td class="e">
    filter.default
  </td>
  
  <td class="v">
    unsafe_raw
  </td>
  
  <td class="v">
    unsafe_raw
  </td>
</tr>

<tr>
  <td class="e">
    filter.default_flags
  </td>
  
  <td class="v">
    <em>no value</em>
  </td>
  
  <td class="v">
    <em>no value</em>
  </td>
</tr>
Directive

使用:
参考本文前边的例子,用 ?email=email@host.com 和 ?email=invalidemail.address 测试。

php interface

PHP代码
  1. interface IA {  
  2.     public function a();  
  3.     public function b();  
  4. }  
  5. class Test implements IA {  
  6.     public function a() {  
  7.         echo ‘aa’;  
  8.     }  
  9.     public function b() {  
  10.         echo ‘bb’;  
  11.     }  
  12.     public function c() {  
  13.         echo ‘cc’;  
  14.     }  
  15. }  
  16.   
  17. class Test2 extends Test {  
  18.     public function a() {  
  19.         echo ‘aaaa!!’;  
  20.     }  
  21. }  
  22. $o = new Test2();  
  23. $o->a();  
  24. ?>  

玩PHP源文件-把LOGO的gif文件转成.h文件中的数据

PHP代码
  1. // 将GIF转换为C语言中的H文件  
  2. $filename = "logo.gif";  
  3. $fp = fopen($filename"rb");  
  4. $buffer = fread($fpfilesize($filename));  
  5. fclose($fp);  
  6. $len = strlen($buffer);  
  7. $fp = fopen("mylogo.h""wb");  
  8. fwrite($fp"unsigned char php_logo[] = {");  
  9. for ($i=0; $i<=$len$i++) {  
  10.     if($i % 10 == 0) {  
  11.         fwrite($fp"\n\t\t");  
  12.     }  
  13.     if($i == $len) {  
  14.         $str = str_pad(ord(substr($buffer$i, 1)), 3, " ", STR_PAD_LEFT);  
  15.     } else {  
  16.         $str = str_pad(ord(substr($buffer$i, 1)), 3, " ", STR_PAD_LEFT) . ", ";  
  17.     }  
  18.     fwrite($fp$str);  
  19. }  
  20. fwrite($fp" };\n");  
  21. fclose($fp);  
  22. ?>  

mysql 备份的PHP脚本

PHP代码
  1.     // 备份数据库  
  2.     function sqldumptable($table$fp=0) {  
  3.         $tabledump = "DROP TABLE IF EXISTS `$table`;\n";  
  4.         $tabledump .= "CREATE TABLE `$table` (\n";  
  5.   
  6.         $firstfield=1;  
  7.   
  8.         $fields = mysql_query("SHOW FIELDS FROM `$table`");  
  9.         while ($field = mysql_fetch_array($fields)) {  
  10.             if (!$firstfield) {  
  11.                 $tabledump .= ",\n";  
  12.             } else {  
  13.                 $firstfield=0;  
  14.             }  
  15.             $tabledump .= "   `$field[Field]` $field[Type]";  
  16.             if (!emptyempty($field["Default"])) {  
  17.                 if($field['Default']!=‘CURRENT_TIMESTAMP’ ) $field['Default'] = "'{$field['Default']}’";  
  18.                 $tabledump .= " DEFAULT $field[Default]";  
  19.             }  
  20.             if ($field['Null'] != "YES") {  
  21.                 $tabledump .= " NOT NULL";  
  22.             }  
  23.             if ($field['Extra'] != "") {  
  24.                 $tabledump .= " $field[Extra]";  
  25.             }  
  26.         }  
  27.         mysql_free_result($fields);  
  28.       
  29.         $keys = mysql_query("SHOW KEYS FROM `$table`");  
  30.         while ($key = mysql_fetch_array($keys)) {  
  31.             $kname=$key['Key_name'];  
  32.             if ($kname != "PRIMARY" and $key['Non_unique'] == 0) {  
  33.                 $kname="UNIQUE|$kname";  
  34.             }  
  35.             if(!is_array($index[$kname])) {  
  36.                 $index[$kname] = array();  
  37.             }  
  38.             $index[$kname][] = $key['Column_name'];  
  39.         }  
  40.         mysql_free_result($keys);  
  41.   
  42.         while(list($kname$columns) = @each($index)) {  
  43.             $tabledump .= ",\n";  
  44.             $colnames=implode($columns,",");  
  45.   
  46.             if ($kname == "PRIMARY") {  
  47.                 $tabledump .= "   PRIMARY KEY ($colnames)";  
  48.             } else {  
  49.                 if (substr($kname,0,6) == "UNIQUE") {  
  50.                     $kname=substr($kname,7);  
  51.                 }  
  52.                 $tabledump .= "   KEY $kname ($colnames)";  
  53.             }  
  54.         }  
  55.   
  56.         $tabledump .= "\n);\n\n";  
  57.         if ($fp) {  
  58.             fwrite($fp,$tabledump);  
  59.         } else {  
  60.             echo $tabledump;  
  61.         }  
  62.   
  63.         $rows = mysql_query("SELECT * FROM `$table`");  
  64.         $numfields = mysql_num_fields($rows);  
  65.         while ($row = mysql_fetch_array($rows)) {  
  66.             $tabledump = "INSERT INTO `$table` VALUES(";  
  67.   
  68.             $fieldcounter=-1;  
  69.             $firstfield=1;  
  70.             while (++$fieldcounter<$numfields) {  
  71.                 if (!$firstfield) {  
  72.                     $tabledump.=", ";  
  73.                 } else {  
  74.                     $firstfield=0;  
  75.                 }  
  76.   
  77.                 if (!isset($row[$fieldcounter])) {  
  78.                     $tabledump .= "NULL";  
  79.                 } else {  
  80.                     $tabledump .= "’".mysql_escape_string($row[$fieldcounter])."’";  
  81.                 }  
  82.             }  
  83.   
  84.             $tabledump .= ");\n";  
  85.   
  86.             if ($fp) {  
  87.                 fwrite($fp,$tabledump);  
  88.             } else {  
  89.                 echo $tabledump;  
  90.             }  
  91.         }  
  92.         mysql_free_result($rows);  
  93.         fwrite($fp,"\n\n\n");  
  94.     }  
  95.   
  96. ?>  

Javascript中的prototype的一个简单例子

XML/HTML代码
  1. >  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3.  <head>  
  4.   <title> new document title>  
  5.   <meta name="generator" content="editplus" />  
  6.   <meta name="author" content="" />  
  7.   <meta name="keywords" content="" />  
  8.   <meta name="description" content="" />  
  9.  head>  
  10.   
  11.  <body>  
  12.   <script type="text/javascript">  
  13.   
  14.     var call = function () {  
  15.         //this.a = function (a) { alert(a); };  
  16.         this.num = 134;  
  17.     }  
  18.     call.prototype.a = function (a) { alert(a); };  
  19.     var v = new call;  
  20.     v.a(v.num);  
  21.   //–>  
  22.   script>  
  23.  body>  
  24. html>  

Javascript下的伪OOP用法测试

JavaScript代码
  1. "text/javascript">  
  2.   
  3. // 方法一  
  4. var cellphone = {  
  5.     number: 13684042440,  
  6.     dial: function  () {  
  7.           
  8.     }  
  9. };  
  10.   
  11. // 方法二  
  12. var cellphone = new Object();  
  13. cellphone.number = 13484042440;  
  14. cellphone.dial = function () {  
  15.     alert("Calling "+this.number);  
  16. }  
  17.   
  18. cellphone.dial();  
  19.   
  20. // 给已有的类追加方法  
  21. String.prototype.trim = function () {  
  22.     var tmp = this.replace(/^\s+/,);  
  23.     tmp = tmp.replace(/\s+$/,);  
  24.     return tmp;  
  25. }  
  26.   
  27. var str = "  sfdfd  sfsd   ";  
  28. str2=str.trim();  
  29. alert("’"+str+"’");  
  30. alert("’"+str2+"’");  
  31.   
  32. function Beesn() {  
  33.     this.member = new Array(‘Kevin’,‘Vonsk’,‘Edison’,‘Michael’,‘Whl’),  
  34.     this.list = function () {  
  35.         for(var i=0;i<this.member.length;i++) {  
  36.             alert(this.member[i]);  
  37.         }  
  38.     },  
  39.     this.show = function () {  
  40.         this.member = this.member.shift();  
  41.         alert(this.member);  
  42.         //for(i in this.member) {  
  43.         //  alert(this.member[i]);  
  44.         //}  
  45.     }  
  46. }  
  47. var our = new Beesn;  
  48. our.show();  
  49.   
  50.   
  51. //arguments 对象的用法。  
  52. function ArgTest(a, b, c){  
  53.    var i, s = "The ArgTest function expected ";  
  54.    var numargs = arguments.length;     // 获取被传递参数的数值。  
  55.    var expargs = ArgTest.length;       // 获取期望参数的数值。  
  56.    if (expargs < 2)  
  57.        s += expargs + " argument. ";  
  58.    else  
  59.        s += expargs + " arguments. ";  
  60.    if (numargs < 2)  
  61.        s += numargs + " was passed.";  
  62.    else  
  63.        s += numargs + " were passed.";  
  64.     s += "\n\n"  
  65.    for (i =0 ; i < numargs; i++){      // 获取参数内容。  
  66.     s += "   Arg " + i + " = " + arguments[i] + "\n";  
  67.     }  
  68.    return(s);                          // 返回参数列表。  
  69. }  
  70. alert( ArgTest(1,our,our) );  
  71.   
  72. // caller demo  
  73. function callerDemo() {  
  74.     if (callerDemo.caller) {  
  75.          var a= callerDemo.caller.toString();  
  76.          alert(a);  
  77.      } else {  
  78.          alert("this is a top function");  
  79.      }  
  80. }  
  81. function handleCaller() {  
  82.      callerDemo();  
  83. }  
  84. callerDemo();  
  85.   
  86. //callee可以打印其本身  
  87. function calleeDemo() {  
  88.      alert(arguments.callee);  
  89. }  
  90. //用于验证参数  
  91. function calleeLengthDemo(arg1, arg2) {  
  92.     if (arguments.length==arguments.callee.length) {  
  93.          window.alert("验证形参和实参长度正确!");  
  94.         return;  
  95.      } else {  
  96.          alert("实参长度:" +arguments.length);  
  97.          alert("形参长度: " +arguments.callee.length);  
  98.          aert(calleeLengthDemo.length);  
  99.      }  
  100. }  
  101. //递归计算  
  102. var sum = function(n){  
  103.   if (n <= 0)                          
  104.   return 1;  
  105.   else  
  106.     return n + arguments.callee(n – 1);  
  107. }  
  108. calleeLengthDemo(1,2,3);  
  109.   
  110. var vehicle=Class.create();  
  111. vehicle.prototype.initialize= function(type)  
  112. {  
  113.         this.type=type;  
  114. }  
  115. vehicle.prototype.showSelf= function()  
  116. {  
  117.       alert("this vehicle is "this.type);  
  118. }  
  119. var Class = {  
  120.    create: function() {  
  121.     returnfunction() {  
  122.       this.initialize.apply(this, arguments);  
  123.      }  
  124.    }  
  125. }  
  126. var moto=new vehicle("Moto");  
  127. moto.showSelf();  
  128.   
  129.   
  130. // 测试extend  
  131. Object.extend = function(destination, source) {  
  132.   for (property in source) {  
  133.     destination[property] = source[property];  
  134.   }  
  135.   return destination;  
  136. }  
  137. Object.prototype.extend = function(object) {  
  138.   return Object.extend.apply(this, [this, object]);  
  139. }  
  140.   
  141. var obj = new Object();  
  142. obj.extend({  
  143.     f1: function () {  
  144.         alert(‘f1′);  
  145.     },  
  146.     f2: function () {  
  147.         alert(‘f2′);  
  148.     }  
  149. });  
  150.   
  151. obj.f2();  
  152.   
  153.   
  154. String.prototype.isEmail = function () {  
  155.     return /^[0-9a-z\-_\.]+@[0-9a-z\-_\.]+\.[a-z]+$/i.test(this);  
  156. };  
  157.   
  158.   
  159. var str = "combbs@msn.com";  
  160. alert(  str.isEmail()  );  
  161.   
  162. //alert(/^[0-9a-z\-_\.]+@[0-9a-z\-_\.]+\.[a-z]+$/i.test(str));  
  163. //–>  
  164.   

测试方法:

请一段一段的测试。测试一段时,先把别的行注释。

Perl 的测试代码

Java代码
  1. #!E:/Perl/bin/perl.exe  
  2. ##  
  3. ##  printenv — demo CGI program which just prints its environment  
  4. ##  
  5.   
  6. print "Content-type: text/html; charset=iso-8859-1\n\n";  
  7. foreach $var (sort(keys(%ENV))) {  
  8.     $val = $ENV{$var};  
  9.     $val =~ s|\n|\\n|g;  
  10.     $val =~ s|"|\\"|g; 
  11.     print "${var}=\"${val}\"\n";  
  12. }