/** * utility functions: check both numbers */ function checkIsOdd($ary) { foreach ($ary as $n) { if (!isOdd($n)) { echo "One of the number you entered is not an valid odd number!\n"; echo "Please restart and try again.\n\n"; exit; } } }
<?php echo isOdd($_POST["xiaoqi"]) ? "奇数" : "偶数"; function isOdd($num) { $ret = $num % 2 == 1; return $ret; echo '123'; }
<?php echo isOdd($_POST['data']) ? '奇数' : '偶数'; function IsOdd($num) { $res = $num % 2 == 1; return $res; }
public function getGrid() { function khonsa_pshowgrid($inp) { return $inp; } function isOdd($inp) { $out = TRUE; if ((int) $inp % 2 == 0) { $out = FALSE; } return $out; } $out = $this->error_message; if ($this->class_enabled) { $out = <<<Holly \t\t\t<div id="{$this->gridName}"> \t\t\t\t<form id="frm_{$this->gridName}" method="post"> \t\t\t\t<input type="hidden" id="selectedField_{$this->gridName}" name="selectedField_{$this->gridName}" value="" /> \t\t\t\t<input type="hidden" id="mod_{$this->gridName}" name="mod_{$this->gridName}" value=""/> \t\t\t\t<input type="hidden" id="pageNumber_{$this->gridName}" name="pageNumber_{$this->gridName}" value="{$this->pageNumber}" /> \t\t\t\t<input type="hidden" id="pageCount_{$this->gridName}" name="pageCount_{$this->gridName}" value="{$this->pageCount}" /> \t\t\t\t<input type="hidden" id="rowCount_{$this->gridName}" name="rowCount_{$this->gridName}" value="{$this->rowCount}" /> \t\t\t\t<script language="javascript"> \t\t\t\t\tfunction readyToEdit_{$this->gridName}(gridName,fieldName){ \t\t\t\t\t\t//alert(gridName+' - '+fieldName); \t\t\t\t\t\tif(document.getElementById(fieldName)){ \t\t\t\t\t\t\t//if(document.getElementById(fieldName).value){ \t\t\t\t\t\t\t\tdocument.getElementById(fieldName).style.display='block'; \t\t\t\t\t\t\t\tif(document.getElementById(fieldName+'_back')){document.getElementById(fieldName+'_back').style.display='none';} \t\t\t\t\t\t\t\tdocument.getElementById(fieldName).focus(); \t\t\t\t\t\t\t//} \t\t\t\t\t\t\tdocument.getElementById('selectedField_{$this->gridName}').value = fieldName; \t\t\t\t\t\t\tdocument.getElementById('mod_{$this->gridName}').value="edit"; \t\t\t\t\t\t} \t\t\t\t\t} \t\t\t\t\tfunction readyToDelete_{$this->gridName}(fieldName){ \t\t\t\t\t\tdocument.getElementById('mod_{$this->gridName}').value="delete"; \t\t\t\t\t\tdocument.getElementById('selectedField_{$this->gridName}').value = fieldName; \t\t\t\t\t\textra_sendObj_{$this->gridName}("frm_{$this->gridName}"); \t\t\t\t\t} \t\t\t\t\tfunction readyToAdd_{$this->gridName}(){ \t\t\t\t\t\tdocument.getElementById('mod_{$this->gridName}').value="add"; extra_sendObj_{$this->gridName}("frm_{$this->gridName}"); \t\t\t\t\t} \t\t\t\t\tfunction extra_sendObj_{$this->gridName}(frm){ \t\t\t\t\t\tdocument.getElementById(frm).submit(); \t\t\t\t\t} \t\t\t\t\tfunction mover_{$this->gridName}(j){ \t\t\t\t\t\tdocument.getElementById('delete_{$this->gridName}'+'_'+j).style.display="block"; \t\t\t\t\t} function mout_{$this->gridName}(j){ document.getElementById('delete_{$this->gridName}'+'_'+j).style.display="none"; } \t\t\t\t\tfunction ifEnter_{$this->gridName}(e){ \t\t\t\t\t\tvar out = false; \t\t\t\t\t var keycode; \t\t\t\t\t if (window.event) keycode = window.event.keyCode; \t\t\t\t\t else if (e) keycode = e.which; \t\t\t\t\t if(parseInt(keycode,10)==13){ \t\t\t\t\t out = true; \t\t\t\t\t } \t\t\t\t\t\treturn(out);\t\t\t\t \t\t\t\t\t} \t\t\t\t\tfunction nextPage_{$this->gridName}(){ \t\t\tdocument.getElementById('mod_{$this->gridName}').value="next"; extra_sendObj_{$this->gridName}("frm_{$this->gridName}");\t\t\t\t\t\t \t\t\t\t\t} \t\t\t\t\tfunction prevPage_{$this->gridName}(){ \t\t\tdocument.getElementById('mod_{$this->gridName}').value="prev"; extra_sendObj_{$this->gridName}("frm_{$this->gridName}");\t\t\t\t\t\t \t\t\t\t\t} \t\t\t\t\tfunction gotoPage_{$this->gridName}(pageindex){ \t\t\t\t\t\tvar pageCount = parseInt(document.getElementById('pageCount_{$this->gridName}').value,10); \t\t\t\t\t\tdocument.getElementById('pageNumber_{$this->gridName}').value=(pageindex-1)*pageCount; \t\t\tdocument.getElementById('mod_{$this->gridName}').value="goto"; extra_sendObj_{$this->gridName}("frm_{$this->gridName}");\t\t\t\t\t\t \t\t\t\t\t} \t\t\t\t</script> Holly; $sums = null; if (is_array($this->eRequest)) { foreach ($this->eRequest as $key => $value) { $out .= "<input type=\"hidden\" id=\"{$key}\" name=\"{$key}\" value=\"{$value}\" />\n"; } } $out .= "<table cellpadding=\"0\" cellspacing=\"0\" width=\"" . $this->width . "\" style=\"border-style:solid;border-width:1px;border-color:Black;\">\n"; $out = $out . "<tr class=\"" . $this->cssClass . "_header\" >\n<th class='" . $this->cssClass . "_gHead' >\n"; $out = $out . $this->indexHeader . "\n"; $out = $out . "<input type=\"hidden\" id=\"row_number\" value=\"0\" />"; $out = $out . "</th>\n"; for ($i = 0; $i < sizeof($this->columnHeaders); $i++) { $out = $out . "<th class='" . $this->cssClass . "_gHead' style=\"" . ($this->columnHeaders[$i] != null ? "" : "display:none;") . "\">\n"; $out = $out . $this->columnHeaders[$i] . "\n"; $out = $out . "</th>\n"; } $out = $out . "</tr>\n"; $j = 1; while ($r = mysql_fetch_array($this->dataSet, MYSQL_ASSOC)) { if (isOdd($j)) { $out = $out . "<tr class=\"" . $this->cssClass . "_row_odd\">\n"; } else { $out = $out . "<tr class=\"" . $this->cssClass . "_row_even\">\n"; } $i = 0; $out = $out . "<td onmouseover=\"mover_" . $this->gridName . "('{$j}');\" onmouseout=\"mout_" . $this->gridName . "('{$j}');\" class=\"" . $this->cssClass . "_row_td\">\n"; $out = $out . ($j + $this->pageNumber) . "\n"; /* if($this->canEdit){ $out = $out . " <u id=\"edit_" . "$j\" style=\"display:none;\"><span style=\"color:Blue;cursor:pointer;\" onclick=\"document.getElementById('row_number').value='$j';" . $this->editFunction . "\">اصلاح</span></u> "; } */ if ($this->canDelete) { $out = $out . " <u id=\"delete_" . $this->gridName . "_{$j}\" style=\"display:none;\"><span style=\"color:Blue;cursor:pointer;\" onclick=\"if(confirm('آیا این رکورد حذف شود؟')){readyToDelete_" . $this->gridName . "('" . $this->gridName . "_{$j}" . "_id');}\">حذف</span></u> "; } $out = $out . "</td>\n"; if ($j == 1) { $sums = $r; if ($sums != null) { foreach ($sums as $key => $value) { $sums[$key] = 0; } } } //foreach($r as $key=>$value){ for ($hasan = 0; $hasan < count($this->fieldList); $hasan++) { $key = $this->fieldList[$hasan]; $value = $r[$key]; if ($this->columnFunctions[$i] == null) { //$fn = function ($inpp){return($inpp);}; $fn = "khonsa_pshowgrid"; } else { $fn = $this->columnFunctions[$i]; } //if($i<sizeof($this->columnHeaders)){ if ($this->columnHeaders[$i] != null) { //.(($this->columnAccesses[$i]==1 && $this->canEdit)?"onclick=\"readyToEdit_".$this->gridName."('".$this->gridName."','".$this->gridName."_$j" . "_$key');\"":""). $out = $out . "<td class=\"" . $this->cssClass . "_row_td\" " . ($this->columnAccesses[$i] == 1 && $this->canEdit && $this->columnLists[$i] == null ? "onclick=\"readyToEdit_" . $this->gridName . "('" . $this->gridName . "','" . $this->gridName . "_{$j}" . "_{$key}');\"" : "") . ">\n"; if ($this->columnLists[$i] == null) { // onblur=\"this.style.display='none';extra_sendObj_".$this->gridName."('frm_".$this->gridName."');\" $out = $out . "<span id=\"" . $this->gridName . "_{$j}" . "_{$key}" . "_back\" style=\"display:block;\">" . ($fn($value) != '' ? $fn($value) : ' ') . "\n</span><input class=\"" . $this->cssClass . "_inp\" " . ($this->columnAccesses[$i] == 1 && $this->canEdit ? "" : "readonly=\"readonly\"") . " type=\"text\" id=\"" . $this->gridName . "_{$j}" . "_{$key}\" name=\"" . $this->gridName . "_{$j}" . "_{$key}\" value=\"{$value}\" style=\"display:none;\" onblur=\"this.style.display='none';extra_sendObj_" . $this->gridName . "('frm_" . $this->gridName . "');\" onkeypress=\"if(ifEnter_{$this->gridName}(event)){this.onblur();}\">"; } else { $out = $out . "<select class=\"" . $this->cssClass . "_inp\" " . ($this->columnAccesses[$i] == 1 && $this->canEdit ? "" : "disabled=\"disabled\"") . " id=\"" . $this->gridName . "_{$j}" . "_{$key}\" name=\"" . $this->gridName . "_{$j}" . "_{$key}\" onchange=\"readyToEdit_" . $this->gridName . "('" . $this->gridName . "','" . $this->gridName . "_{$j}" . "_{$key}');extra_sendObj_" . $this->gridName . "('frm_" . $this->gridName . "');\" onkeypress=\"if(ifEnter_{$this->gridName}(event)){this.onchange();}\" >\n" . $this->columnListToCombo($this->columnLists[$i], $value) . "</select>\n"; } $out = $out . "</td>\n"; if ($key == 'Total') { $sums[$key] = (int) $sums[$key] + ($fn($value) != '' ? (int) $value : 0); } else { $sums[$key] = (int) $sums[$key] + ($fn($value) != '' ? (int) $fn($value) : 0); } } else { $out = $out . "<td style=\"display:none;border-style:solid;border-width:1px;border-color:Black;text-align:center;font-family:Tahoma,tahoma;font-size:small;\">\n"; $out = $out . ($fn($value) != '' ? $fn($value) : ' ') . "<input type=\"text\" id=\"" . $this->gridName . "_{$j}" . "_{$key}\" name=\"" . $this->gridName . "_{$j}" . "_{$key}\" value=\"{$value}\">\n"; $out = $out . "</td>\n"; $sums[$key] = (int) $sums[$key] + ($fn($value) != '' ? (int) $fn($value) : 0); } $i++; } $out = $out . "</tr>\n"; $j++; } $out = $out . "<tr class=\"" . $this->cssClass . "_insert_row\">\n"; $out = $out . "<td colspan=\"" . (sizeof($this->columnHeaders) + 1) . "\" style=\"border-style:solid;border-width:1px;border-color:Black;text-align:right;font-family:Tahoma,tahoma;font-size:small;\">\n"; $out = $out . "<input type=\"button\" class=\"" . $this->cssClass . "_insert_button\" value=\"بعدی\" onclick=\"nextPage_" . $this->gridName . "();\" " . ($this->rowCount / $this->pageCount <= 1 ? "disabled=\"disabled\"" : "") . "/>"; $out .= $this->createPageNumbers(); $out = $out . "<input type=\"button\" class=\"" . $this->cssClass . "_insert_button\" value=\"قبلی\" onclick=\"prevPage_" . $this->gridName . "();\" " . ($this->pageNumber <= 0 ? "disabled=\"disabled\"" : "") . "/>"; //$out = $out . "<input type=\"button\" class=\"" . $this->cssClass . "_insert_button\" value=\"قبلی\" onclick=\"prevPage_".$this->gridName."();\" />"; $out = $out . "</td>\n"; $out = $out . "</tr>\n"; $out = $out . $this->footer; $out .= $this->canAdd ? "<tr class=\"" . $this->cssClass . "_row_even\"><td class=\"" . $this->cssClass . "_row_td\">ثبت جدید</td>\n" : ""; for ($i = 0; $i < sizeof($this->fieldList) && $this->canAdd; $i++) { $out = $out . "<td class=\"" . $this->cssClass . "_row_td\" style=\"" . ($this->columnHeaders[$i] != null ? "" : "display:none;") . "\">\n"; if ($this->columnLists[$i] == null) { $out = $out . "<input class=\"" . $this->cssClass . "_inp\" type=\"text\" id=\"new_" . $this->fieldList[$i] . "\" name=\"new_" . $this->fieldList[$i] . "\" value=\"\" />\n"; } else { $out = $out . "<select id=\"new_" . $this->fieldList[$i] . "\" name=\"new_" . $this->fieldList[$i] . "\">\n" . $this->columnListToCombo($this->columnLists[$i], null) . "</select>\n"; } $out = $out . "</td>\n"; } $out .= $this->canAdd ? "</tr>\n" : ""; if ($this->canAdd) { $out = $out . "<tr class=\"" . $this->cssClass . "_insert_row\">\n"; $out = $out . "<td colspan=\"" . (sizeof($this->columnHeaders) + 1) . "\" style=\"border-style:solid;border-width:1px;border-color:Black;text-align:left;font-family:Tahoma,tahoma;font-size:small;\">\n"; $out = $out . "<input type=\"button\" class=\"" . $this->cssClass . "_insert_button\" value=\"ثبت\" onclick=\"readyToAdd_" . $this->gridName . "();\" />"; $out = $out . "</td>\n"; $out = $out . "</tr>\n"; } // if($r = mysql_fetch_array($dataSet,MYSQL_ASSOC)){ $out = $out . "<tr>\n"; if ($sums != null) { foreach ($sums as $key => $value) { $out = $out . "<td id=\"sum_{$key}\" style=\"display:none;border-style:solid;border-width:1px;border-color:Black;text-align:center;font-family:B Titr,b titr,B titr,b Titr,Tahoma,tahoma;font-size:medium;\">\n"; $out = $out . $value . "\n"; $out = $out . "</td>\n"; } } $out = $out . "</tr>\n"; // } $out = $out . "</table>"; $out .= "</form></div>"; } $this->sums = $sums; return $out; }
function combi4($x, $y, $z) { $a = isEven($x); $b = isOdd($y); return someLogic($a, $b, $z); }