public function __construct($host = 'localhost', $port = 9090, $persist = false, $debugHandler = null) { $this->host_ = $host; $this->port_ = $port; $this->persist_ = $persist; $this->debugHandler_ = \hacklib_cast_as_boolean($debugHandler) ?: fun('error_log'); }
public function __construct($host = "localhost", $port = 9090, $debugHandler = null) { $this->host_ = $host; $this->port_ = $port; $this->ipV6_ = \hacklib_equals(strlen(inet_pton($host)), 16); $this->debugHandler_ = \hacklib_cast_as_boolean($debugHandler) ?: fun("error_log"); }
function main($c1, $c2, $c3, $c4) { $o = new d(); $o->prop = new d(); fun($o); var_dump($c1, $c2, $c3, $c4); }
/** * Convertir un array en * */ function fun($array, DOMDocument $xml, DOMElement $element) { foreach ($array as $key => $value) { if (is_array($value)) { fun($value, $xml, $element); } else { $node = $xml->createElement($key, $value); $element->appendChild($node); } } }
public function __construct($host, $port = 80, $uri = "", $scheme = "http", $debugHandler = null) { if (\hacklib_cast_as_boolean($uri) && \hacklib_not_equals($uri[0], "/")) { $uri = "/" . $uri; } $this->scheme_ = $scheme; $this->host_ = $host; $this->port_ = $port; $this->uri_ = $uri; $this->buf_ = ""; $this->data_ = ""; $this->errstr_ = ""; $this->timeout_ = null; $this->custom_headers_ = null; $this->debugHandler_ = \hacklib_cast_as_boolean($debugHandler) ?: fun("error_log"); }
<p> Some text to wrap. Some text to wrap. Some text to wrap. Some text to wrap. Some text to wrap. Some text to wrap. Some text to wrap. <?php fun(); ?> Some text to wrap. Some text to wrap. Some text to wrap. Some text to wrap. Some text to wrap. Some text to wrap. Some text to wrap. </p>
<?php function fun() { $x = array(); for ($y = 1; $y <= 100; $y++) { $temp['num'] = $y; $temp['sqr'] = $y * $y; $temp['cube'] = $y * $y * $y; array_push($x, $temp); } return json_encode($x); } echo fun();
{ function __construct() { echo __NAMESPACE__, '<br/>';//返回当前命名空间名称的字符串,若没有命名空间,则返回空字符串 } function get($classname) { if (!class_exists($classname)) { $a = __NAMESPACE__ . '\\' . $classname; return new $a; } } } class Test { function __construct() { echo __METHOD__, '<br/>'; } } function fun() { echo __FUNCTION__, '<br/>'; } $cnp = new ClassNamespaceconst(); $cnp->get('Test'); namespace\fun();//使用namespace操作符,调用当前命名空间下的fun();
$sample_code = str_replace("\n", ' ', $fi_str); $sample_code = str_replace("\\", "", $sample_code); $fi_str = $fi_str; fwrite($fp, $fi_str, strlen($fi_str)); $cmd = "g++" . " " . $file_name; system($cmd . '>error.txt 2>&1'); $error = file_get_contents("error.txt"); if (empty($error)) { $run = "./a.out"; if ($stat == "test") { system($run . '< inp.txt >err1.txt 2>&1'); $output = explode("\n", file_get_contents("err1.txt")); unlink($run); } else { if ($stat == "submit") { fun($run, $ques); } } } else { unset($output); $error = explode("\n", file_get_contents("error.txt")); } } } } } else { //echo "hello"; echo "<script>alert(\"please upload a file or write a code in given text area\");</script>"; } } }
} ?> </div> <div class="a3"> <form method="post" action=""> <textarea id="b1" name="hua" cols="50" rows="5" placeholder="想说的话"> </textarea><br/> <input type="submit"value="发送消息"/></input> </form> <input type="button" value="刷新消息" onclick="test()"/></input> <?php date_default_timezone_set('Etc/GMT-8'); //这里设置了时区 $a = date("Y-m-d h:i:sa"); $w = $a . $nn . ':' . $_POST[hua]; fun($w); ?> </div> </div> <p><font color="#EE82EE"><center>作者海贼王</center></font></p> </div> <?php function fun($word) { $filename = './aa.txt'; $fp = fopen($filename, 'a'); fwrite($fp, $word . "\n"); fclose($fp); } ?> </body>
<?php //Created a function to add the random number //Random number generation with assumption of including 6 and 15 function fun($x) { $a = rand(6, 15); $x = $x . " " . $a; //Concatenated with a space. return $x; } //Accessing php file without filling form not possible if (empty($_POST['submit']) && empty($_GET['user'])) { header('Location: main.php'); exit; } $a = mysql_escape_string($_GET['user']); echo fun($a); ?> <h3>Want to try again</h3> <a href="main.php">Main page</a>
<?php $str = <<<EOD \tHello World php EOD; echo $str; function fun($a, $b) { return $a + $b; } echo "12+30=" . fun(12, 30) . "<br/>" . "ttt" . "<br/>"; $arr1 = array('A', 'B', 'C'); echo $arr1[0] . $arr1[1] . $arr1[2]; echo "<br/>"; echo is_array($arr1) ? "arr1 是数组" : "arr1 不是素组"; echo "<br/>"; print_r($arr1); $search = 100; $language = array("100", "200", "300"); // 地上那个参数默认为false如果为true,则检查搜索的数据与数组的值的类型是否相同 if (in_array($search, $language, true)) { echo "100存在language中"; } else { echo "100不存在language中"; } echo "<br/>"; foreach ($language as $key => $value) { echo $value . "<br>"; echo $key . "<br>"; } echo "_SERVER = ";
function print_details() { /* show error page */ // Request access to the global variables we need global $fontface, $fontsize, $docroot, $REQUEST_URI, $PHP_SELF; global $bgcolor, $textcolor; global $currentlang; list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); $sitename = pnConfigGetVar('sitename'); $reportlevel = pnConfigGetVar('reportlevel'); $funtext = pnConfigGetVar('funtext'); $top = pnConfigGetVar('top'); if (pnConfigGetVar('multilingual') == 1) { $queryalang = "WHERE (alanguage='{$currentlang}' OR alanguage='')"; /* top stories */ } else { $queryalang = ""; } global $HTTP_SERVER_VARS; global $doc; $doc = getenv('REDIRECT_URL'); if (empty($HTTP_SERVER_VARS['HTTP_HOST'])) { $server = getenv('HTTP_HOST'); } else { $server = $HTTP_SERVER_VARS['HTTP_HOST']; } $doc = "http://{$server}{$doc}"; include "header.php"; OpenTable(); ?> <a class="pn-logo"><?php echo "" . _ERR404 . ""; ?> </a><br> <font class="pn-logo-small"><?php echo "" . _ERRPAGENF . " "; echo $doc; ?> </font><hr> <?php echo "<font class=\"pn-normal\">" . _ERRSORRY . ", {$doc}, "; echo "" . _ERRDOESNTEXIST . " \" {$sitename} \"<P></font>"; if ($reportlevel != 0) { echo "<p><font style=\"pn-normal\">"; echo "" . _ERRMAILED . ""; } if ($funtext != 0) { fun(); } ?> <br><p> <a class="pn-storytitle"><?php echo "" . _ERRCOMMONM . ""; ?> </a><br> <font class="pn-normal"><?php echo "" . _ERRCOMMONH . ""; ?> <?php echo "{$sitename}"; ?> : <UL> <LI><?php echo "" . _ERRURLEND . ""; ?> <CODE>.htm</CODE> - <STRONG><?php echo "" . _ERRALLPAGES . " \"{$sitename}\" " . _ERRENDWITH . ""; ?> <CODE>.php</CODE></STRONG> <LI><?php echo "" . _ERRUPPERCASE . ""; ?> - <STRONG><?php echo "" . _ERRALLLOWER . ""; ?> </STRONG> </UL></font></p> <a class="pn-storytitle"><?php echo "" . _ERRPOPPAGES . ""; ?> </a><br> <?php /*** * fifers: don't know what the $alanguage does here. left it in * because it always seems to be empty and I wasn't sure what it * was doing! */ $column =& $pntable['stories_column']; $sql = "SELECT {$column['sid']}, {$column['title']}, {$column['time']}, {$column['counter']} FROM {$pntable['stories']} ORDER BY {$column['counter']} DESC"; $result = $dbconn->SelectLimit($sql, $top); if ($result === false) { PN_DBMsgError($dbconn, __FILE__, __LINE__, "Error"); } if (!$result->EOF) { echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n" . "<font class=\"pn-title\">{$top} " . _READSTORIES . "</font><br><br>\n"; $lugar = 1; while (list($sid, $title, $time, $counter) = $result->fields) { if ($counter > 0) { $mode = pnUserGetVar('umode'); if (!empty($mode)) { $commentlink = "&mode={$mode}"; } else { $commentlink = '&mode=thread'; } echo "<font class=\"pn-normal\"> {$lugar}:</font> <a href=\"modules.php?op=modload&name=News&file=article&sid={$sid}{$commentlink}\">{$title}</a><font class=\"pn-normal\"> - ({$counter} " . _READS . ")</font><br>\n"; $lugar++; } $result->MoveNext(); } echo "</td></tr></table><br>\n"; } ?> </font><br> <a class="pn-storytitle"><?php echo "" . _ERRTRYHOME . ""; ?> </a></br> <font class="pn-normal"><?php echo "" . _ERRSTARTHERE . ""; ?> <A HREF="/"> <?php echo "{$sitename}</a> " . _ERRHP; ?> .</font> <p> <a class="pn-storytitle"><?php echo "" . _SEARCH . ""; ?> </a></br> <font class="pn-normal"><?php echo "" . _ERRFOPTION . ""; ?> . <CENTER><form action="modules.php" method=post> <!-- Credit to Mayday (mayday6971) for fix --> <input type="hidden" name="active_stories" value="1"> <input type="hidden" name="bool" value="AND"> <input type="hidden" name="stories_cat" value=""> <input type="hidden" name="stories_topics" value=""> <input type="hidden" name="op" value="modload"> <input type="hidden" name="name" value="Search"> <input type="hidden" name="file" value="index"> <input type="hidden" name="action" value="search"> <input type="hidden" name="overview" value="1"> <font size="-1" color="#000000"><br><b> <?php echo "" . _SEARCH . ""; ?> <?php echo $sitename; ?> </b><br> <input class="pn-text" type=name name=query size="25"></font></form></CENTER> <CENTER><form action="modules.php" method=post> <!-- Credit to Mayday (mayday6971) for fix --> <input type="hidden" name="active_stories" value="1"> <input type="hidden" name="stories_author" value=""> <input type="hidden" name="bool" value="AND"> <input type="hidden" name="stories_cat" value=""> <input type="hidden" name="q" value=""> <input type="hidden" name="op" value="modload"> <input type="hidden" name="name" value="Search"> <input type="hidden" name="file" value="index"> <input type="hidden" name="action" value="search"> <input type="hidden" name="overview" value="1"> <FONT size="-1"><BR><B><?php echo "" . _SEARCH . ""; ?> </B><?php echo "" . _TOPIC . ""; ?> <BR> <!-- Topic Selection --> <?php echo "<select class=\"pn-text\" NAME=\"topic\"onChange='submit()'>"; $column =& $pntable['topics_column']; $query = "SELECT {$column['tid']}, {$column['topictext']}\n FROM {$pntable['topics']}\n ORDER BY {$column['topictext']}"; $toplist = $dbconn->Execute($query); echo "<option value=\"\">" . _SELECTTOPIC . "</option>\n"; while (list($topicid, $topics) = $toplist->fields) { $toplist->MoveNext(); if ($topicid == $topic) { $sel = "selected "; } echo "<option {$sel} value=\"{$topicid}\">{$topics}</option>\n"; $sel = ""; } echo "</select>"; ?> </FONT></FORM></CENTER> </p> <a href="#" onload="type_text()"></a> <?php CloseTable(); include "footer.php"; }
echo "\n"; // Same again, but the variable passed in is now part of a // change-on-write set (references another variable). // In this section, in all cases where a pass-by-reference is involved, // both variables should be changed. $m = 90; $n =& $m; fun($n); var_export($m); var_export($n); $m = 'y'; var_export($m); var_export($n); $o = 100; $p =& $o; fun(&$p); var_export($o); var_export($p); $p = 'y'; var_export($o); var_export($p); $q = 110; $r =& $q; fun_r($r); var_export($q); var_export($r); $r = 'y'; var_export($q); var_export($r); $s = 120; $t =& $s;
<?php function fun($x) { $x = 'x'; } $g = 60; $h = $g; fun(&$h); var_export($h);
<th style="border-right: 2px solid #3E3536;border-top:0;border-bottom:0;background: #3E3536;">全功能版</th> </tr> </thead> <tbody> <?php $t = true; foreach ($arr as $i => $ki) { echo "<tr>"; $t = !$t; foreach ($ki as $j => $kj) { $kj = str_replace(' ', '<br>', $kj); if ($j < 2) { if ($kj != '') { $n = fun($arr, $i, $j); echo "<td rowspan='$n'>$kj</td>"; } } else { if ($kj == '有') { $kj = '√'; } else if ($kj == '无') { $kj = ''; } if ($t) { echo "<td style='background: #F0F0F0;'>$kj</td>"; } else { echo "<td>$kj</td>"; } } }
<?php namespace PhpTestProject; include('php_namespace_basic2.php'); /** * 命名空间基础 */ class ClassNamespaceBasic { function __construct() { echo __METHOD__, '<br/>'; } } function fun() { echo __METHOD__, '<br/>'; } fun();//非限定名称,直接是以当前命名空间进行解析 new ClassNamespaceBasic(); basic\fun();//限定名称,会以当前文件的所在的命名空间进行解析 new basic\ClassNamespaceBasic(); \PhpTestProject\basic\fun();//完全限定名称,必须最前需要用反斜杠 new \PhpTestProject\basic\ClassNamespaceBasic();