/** * Implements functionThatShouldNotShowUp(); */ function test_function() { // Test a normal function should work properly. normalFunction('test data'); // Test exceptions: start simple - call a function that doesn't exist with a space in between the function name // and "(". functionThatDoesNotExist('param1', 'param2'); functionThatDoesNotExist2('param1', 'param2'); // Call a function within a function. abc(def('abc')); // Use a constant, that can be misconstrued as a function potentially. $test_result = 3 - TEST_CONST; // Test referring to an object. $testJsonResponse = (object) array('data' => 'abc'); $testJsonResponse->data = 'abc'; $result = drupal_json_decode($json->data); // Create a reference to returned value $a =& reference_returner_function(); // Static method call StaticTestClass::staticFunctionCall(); // Method call $someInstance->someMetod(); // Creating a class $a = new stdClass(); }
public function testGenerateMockFunctions() { // Generate a stub method dynamically and ensure you can call it. FunctionMock::generateMockFunctions(array('./test_php.php')); FunctionMock::stub('abc', 3); $this->assertEquals(3, abc('http://abc.com/get')); }
function abc($n) { if ($n <= 1) { return 1; } else { return $n + abc($n - 1); } }
<?php /* This is an example, which demonstrates the difference * between --$a, $a-- * ++$a and $a++ */ $a = 0; //if (--$a == 0) echo '-1 is not == 0' . $a; //will echo nothing and programm stops if ($a-- == 0) { echo 'True, 0 == 0 and after checking $a is decremented and becomes ' . $a . '<br>'; } //will echo 'True, 0==0 and after checking $a is decremented and becomes --1' /* Now example * with created * function*/ function abc() { $a = 0; if ($a-- == 0) { $b = $a; } //'wwwwTrue, 0 == 0 and after checking $a is decremented and becomes ' . $a .' '; //will echo 'True, 0==0 and after checking $a is decremented and becomes --1' return $b; } echo '<br>' . ' Now ' . abc();
<?php function abc() { return md(); } function aa() { return 1; } //더 쓸모 없는 주석 echo "===> " . abc() . aa();
<?php /** * Created by PhpStorm. * User: janhuang * Date: 15/8/14 * Time: 下午2:10 * Github: https://www.github.com/janhuang * Coding: https://www.coding.net/janhuang * SegmentFault: http://segmentfault.com/u/janhuang * Blog: http://segmentfault.com/blog/janhuang * Gmail: bboyjanhuang@gmail.com * WebSite: http://www.janhuang.me */ include __DIR__ . '/../vendor/autoload.php'; $debug = \FastD\Debug\Debug::enable(); try { echo abc(); } catch (Exception $e) { echo $e->getMessage(); }
/** * A very long and complicated class method */ public function example12() { if ($a == $b) { if ($a1 == $b1) { fiddle(); } else { if ($a2 == $b2) { fiddle(); } else { fiddle(); } } } else { if ($c == $d) { while ($c == $d) { fiddle(); } } else { if ($e == $f) { for ($n = 0; $n < $h; $n++) { fiddle(); } } else { switch ($z) { case 1: fiddle(); break; case 2: fiddle(); break; case 3: fiddle(); break; default: fiddle(); break; } } } } if ($a == $b) { if ($a1 == $b1) { fiddle(); } else { if ($a2 == $b2) { fiddle(); } else { fiddle(); } } } else { if ($c == $d) { while ($c == $d) { fiddle(); } } else { if ($e == $f) { for ($n = 0; $n < $h; $n++) { fiddle(); } } else { switch ($z) { case 1: fiddle(); break; case 2: fiddle(); break; case 3: fiddle(); break; default: fiddle(); break; } } } } // Just to make sure the class method is very long abc(); xyz(); abc(); xyz(); abc(); xyz(); abc(); xyz(); }
<title>Delete Subject - Admin</title> <link rel="stylesheet" type="text/css" href="delsub.css"> </head> <body> <header> <img src ="../images/tellus-logo.png"/> <span> <a href="../logout.php">Logout</a> </span> </header> <article> <h1>Delete a Record from Student:</h1> <form action="delsub.php" method=POST> <div class=input> <?php abc(); ?> <button type=submit>Delete</button> </div> <div class=output> <?php $obDBRelb = new DBRel(); $conn = $obDBRelb->DBConn(); $sql = "SELECT * FROM Subject order by Sub_No"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table class=slist>"; echo "<tr>"; echo "<th>Subject No.</td>"; echo "<th>Subject Name</td>"; echo "</tr>";
<?php function abc($a) { if ($a === null) { try { throw new exception("dddd"); } catch (Exception $e) { // do nothing ... } } return $a + 10; } witness_start('test:123'); $b = abc(null); print_r($b);
function showPollGroupStat($group) { echo '<div class="poll_item">'; echo '<center><h1>' . $group['title'] . '</h1></center>'; echo '<center><p style="padding-bottom: 30px;">' . $group['description'] . '</p></center>'; $polls_group = getPollsFromGroup($group['groupId']); foreach ($polls_group as $poll) { echo '<div id="pollsGoogle">'; $link = ''; abc($poll['title'], $poll, $link); echo '</div>'; } $linkFB = getGroupUrl($group['titleHash']); /*funcao está em utilities/getPollURL.php */ $linkTwitter = getGroupUrlFull($group['titleHash']); ?> <!-- Codigo comentado porque demorava muito a fazer loading dos butoes de share, mas estes têm contadores de shares --> <!-- <div id="twitter"> <a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo $linkTwitter; ?> " data-text="Check out this results on Polly: '.$group['title'].'" data-size="large" data-hashtags="polly" data-dnt="true"> </a> </div> <div> <span class="g-plus" data-action="share" data-href="<?php echo $linkTwitter; ?> "></span> </div> <div> <span id="facebook"><div class="fb-share-button" data-href="'.$linkFB.'" data-layout="button_count" ></div> </span> </div> --> <!-- Versão simplista dos shares --> <div id="sharebuttons"> <ul class="share-buttons"> <li><a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $linkTwitter; ?> &t=Check%20out%20this%20results%20on%20Polly%3A" target="_blank"><img src="img/Facebook.png"></a></li> <li><a href="https://twitter.com/intent/tweet?source=<?php echo $linkTwitter; ?> &text=Check%20out%20this%20results%20on%20Polly%3A: <?php echo $linkTwitter; ?> " target="_blank" title="Tweet"><img src="img/Twitter.png"></a></li> <li><a href="https://plus.google.com/share?url=<?php echo $linkTwitter; ?> " target="_blank" title="Share on Google+"><img src="img/Google+.png"></a></li> </ul> </div> <?php echo '</div>'; }
include 'templates/header.php'; include 'database/polls_fetch.php'; include 'pollgoogle.php'; include_once 'getPollURL.php'; $poll_hash = $_GET['poll']; $poll = getPollByHash($poll_hash); ?> <div class="poll_item" style="overflow: hidden;"> <script>alert(<?php echo $poll_hash; ?> )</script> <?php $link = getPollUrl($poll_hash); abc($poll['title'], $poll, $link); ?> </div> <?php include 'templates/footer.php'; ?> <?php include 'templates/header.php'; include 'user.php'; include 'database/polls_fetch.php'; include "pollgoogle.php"; include 'showPolls.php'; if (isset($_GET['group'])) {
function abcd($aaaaa, $bbbbb) { $ccccc = $aaaaa - $bbbbb; return abc($ccccc, $aaaaa + $bbbbb); }
<?php $a = 1; class MoneyBags { } function abc(&$foobar) { return $foobar; } $right = abc($a); $wrong = abc(&$a); $a = E_STRICT; // Sniffer checks strings, and returns if no left paren afterwards abc($x, $y, $z, &$a); // nested function call preg_replace($a, $b, trim(&$a)); foobar(3 & $a); // LNUMBER + & foobar($a & $b); // variable + & foobar($b[0] & $a); // square bracket + & foobar($a & $b); // parenthesis + & foobar(intval(3) & $b); // function + & foobar(&$b);
<?php isset(abc());