Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

asdasg345

php

<?php

class Design
{
    public $id = null;
    protected $attributes = [
        'id' => '',
        'name' => '',
    ];

    /**
     * Set fields and return design instance.
     * @param $design_data
     * @return $this
     */
    public function saveDesignData($design_data)
    {
        $this->attributes['name'] = $design_data['name'];
        // Make other save stuff.
        return $this;
    }

    /**
     * Save shipping into database (default Eloquent Model save).
     * @return $this
     */
    public function save()
    {
        // Assume design saved to database and we have id.
        // But now we set id just here for example.
        $this->attributes['id'] = rand(0, 10000);
        return $this;
    }
	
	public function getAttributes()
	{
		return $this->attributes;	
	}
	
    public function getId()
    {
        return $this->attributes['id'];
    }
}


class Shipping
{

    protected $attributes = [
        'id' => '',
        'type_of_delivery' => '',
        'address' => '',
        'design_id' => '',
    ];

    public function getId()
    {
        return $this->attributes['id'];
    }
	
	public function getAttributes()
	{
		return $this->attributes;	
	}

    /**
     * Set fields and return shipping instance.
     * @param $shipping_data
     * @return $this
     */
    public function saveShippingData($shipping_data)
    {
        $this->attributes['type_of_delivery'] = $shipping_data['type_of_delivery'];
        $this->attributes['address'] = $shipping_data['address'];
        return $this;
    }

    /**
     * Save shipping into database (default Eloquent Model save).
     * @return mixed
     */
    public function save()
    {
        // Assume shipping saved to database and we have id.
        // But now we set id just here for example.
        $this->attributes['id'] = rand(0, 10000);
        return $this;
    }

    /**
     * @param $id
     * @return $this
     */
    public function associateDesign($id)
    {
        $this->attributes['design_id'] = $id;
        return $this;
    }
}

class UniqueKeyIdPairsTempStoreHelper
{
    protected $uniqueKeyIdPairs = [];

    /**
     * Add key/id pair.
     * @param $uniqueKey
     * @param $id
     */
    public function addUniqueKeyIdPair($uniqueKey, $id)
    {
        $this->uniqueKeyIdPairs[$uniqueKey] = $id;
    }

    /**
     * Get id by unique key.
     * @param $uniqueKey
     * @return mixed|null
     */
    public function getIdByUniqueKey($uniqueKey)
    {
        return !empty($this->uniqueKeyIdPairs[$uniqueKey]) ? $this->uniqueKeyIdPairs[$uniqueKey] : null;
    }
}
// Init database.
$database = [];
/**
 * Assume we create Order and its Designs in OrderController.
 */
$design_post = [
    'design1' => [
        'name' => 'Design #1',
        'designUniqueKey' => 'Iasfuhh2323lk4n1',
        // Other design data from frontend.
    ],
    'design2' => [
        'name' => 'Design #2',
        'designUniqueKey' => 'asf54fuhh2323lk4n2',
        // Other design data from frontend.
    ]
];

// Before loop design creation make a new instance of temp unique key and ids store.
$tempDesignIdsStore = new UniqueKeyIdPairsTempStoreHelper();

// Loop design post and save each design into database.
foreach ($design_post as $design_data) {
    $design = new Design(); // Create design instance

    /*
     * Bunch of code here. Set design fields, create relations(finishings, garments, etc.)
     */
    $design->saveDesignData($design_data);

    $design->save(); // Call save method and design will be stored in database.
    
    
    
    $database['designs'][$design->getId()] = $design->getAttributes();
    /*
     *  Now we can access design id and save it to temp store.
     *  $design_data will store uniqueKey for new designs on estimate form. (ask frontend develop to do it).
     */
    $tempDesignIdsStore->addUniqueKeyIdPair($design_data['designUniqueKey'], $design->getId()); //
}

/*
 * Now you can use $tempDesignIdsStore below for other part of Order saving proccess.
 * See example.
 */

$shippings_post = [
    'shipping1' => [
        'address' => 'Ukraine, Kharkiv, XTZ',
        'type_of_delivery' => 'shipping',
        // More fields for shipping.
        // ...
        'designUniqueKey' => 'Iasfuhh2323lk4n1'
    ],
    'shipping2' => [
        'address' => 'Ukraine, Kharkiv, Moskov ave.',
        'type_of_delivery' => 'shipping',
        // More fields for shipping.
        // ...
        'designUniqueKey' => 'asf54fuhh2323lk4n2'
    ],
    'shipping3' => [
        'address' => 'United States, Florida, Some Street',
        'type_of_delivery' => 'pickup',
        // More fields for shipping.
        // ...
        'designUniqueKey' => 'Iasfuhh2323lk4n1'
    ]
];

foreach ($shippings_post as $shipping_data) {
    // Get design from temp store by unique key attached on estimate form on shipping step.
    $design_id = $tempDesignIdsStore->getIdByUniqueKey($shipping_data['designUniqueKey']);


    /*
     * Create shipping address,
     * Create shipping,
     * Use design id from temp store to associate shipping and design
     */
    $shipping = new Shipping();
    $shipping->saveShippingData($shipping_data);
    $shipping->save();
    
    $shipping->associateDesign($design_id);

    $database['shippings'][$shipping->getId()] = $shipping->getAttributes();
}

print_r($database);

discuz_xss

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>

<script>
var value='RE: <?php
    echo htmlspecialchars(json_encode(str_replace('\'', '\\\'', "\'-alert(document.cookie)//")));
?>'
</script>
</body>
</html>

DADD

php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="author" content="University of Nairobi"/>
    <meta name="description" content="Student Management Information System"/>
    <meta name="keywords" content="key, words"/>
    <link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
    <style type="text/css">
        @import url(/styles/main.css);    </style>
    <title>University of Nairobi : Students Online Portal</title>
</head>
<body>
<div id="content">
    <div id="top_info">
        <div id="logo">
            <a href="/index.php" title="Home">
                <img src="/images/logo.jpg" class="logoimg"/></a>
        </div>
        <div class="title">
            <h1><a href="" title="University of Nairobi Home Page">
                    University of Nairobi </a></h1>
            <p id="slogan" title="A world-class university committed to scholarly excellence">A world-class university
                committed to scholarly excellence</p>
        </div>
    </div>
        <ul id="tablist">
        <li><a  href="/index.php"                    accesskey="H"> Portal Home </a></li>
        <li><a  href="/statement_summary.php"                    accesskey="S"> Student Fees</a></li>
        <li><a  href="/teaching_timetable.php"                    accesskey="T"> Timetables</a></li>
        <li><a  href="/course_registration.php"                    accesskey="C"> Course Registration</a></li>
        <li><a  class="current"  href="/result_slips.php"                    accesskey="R"> Results</a></li>
        <li><a  href="/student_enquiries.php"                    accesskey="E"> Enquiries </a></li>
        <li><a  href="https://smis.uonbi.ac.ke/hamis/bookroom.php"                    accesskey="E"> Book Room </a></li>
        <li><a  href="/index.php?smisLogout=true"                    accesskey="L"> Logout </a></li>
    </ul>
    <div id="topics">
        <div class="thirds"><ul> <li><a href="/result_slips.php">Provisional Result Slip</a></li></ul></div><div class="thirds"><ul> <li><a href="/enquiries.php">Transcript Request</a></li></ul></div>    </div>
    	  
<div id="left">
	<div class="left_articles">
	<div> <p>D33/32676/2014 LUCAS AWEYO OGADA &nbsp; &nbsp; (Nairobi Day(Mod II)) </p></div><p class="center">
<table border="0" align="center" cellspacing="0" cellpadding="0">
<tr><td align="center"> D33 BACHELOR OF COMMERCE</td> </tr> 
<tr><td align="center"> <p>  While every effort is made to ensure that details are correct and up-to-date, <br />  please reconfirm with your Faculty/School/Institute office in case of any missing unit. <br /> Please note that NOT ALL Faculties, Schools and Institutes have released their results online. </p></td> </tr> 
<tr><td align="center"> 
<table border="0" align="center" cellspacing="0" cellpadding="0" width=100% >
  <tr> <td align="center"><a href="/result_slips.php?realm=showCourseWork"> Show CAT(S) / Course Work </a> &nbsp;  &nbsp; <a href="/result_slips.php?realm=level"> Order Results by Level </a> 
 </td> </tr> 
 </table>
 
 
<table border="1" align="center" cellspacing="0"  cellpadding="0" width=100%>
 <tr> <td align="center" colspan="5"><B> Released Exam Results </B></td> </tr> 
<tr> <td align="left" colspan="5">2013/2014  May-August </td> </tr> 
<tr align="center"> <td align="center"> Cumulative </td> <td > &nbsp; </td> <td > Code  </td>  <td > Course Title </td>  <td > Grade </td>  </tr> 
<tr align="left"> <td align="center"> 1 </td> 
 <td > 1 </td> 
<td > CCS001 &nbsp;</td> 
<td > COMMUNICATION SKILLS &nbsp;</td> 
<td > C &nbsp;</td> 
 </tr> 
<tr align="left"> <td align="center"> 2 </td> 
 <td > 2 </td> 
<td > CCS010 &nbsp;</td> 
<td > HIV AND AIDS INSTRUCTIONS &nbsp;</td> 
<td > A &nbsp;</td> 
 </tr> 
<tr align="left"> <td align="center"> 3 </td> 
 <td > 3 </td> 
<td > DAC101 &nbsp;</td> 
<td > FUNDAMENTALS  OF FINANCIAL ACCOUNTING I &nbsp;</td> 
<td > B &nbsp;</td> 
 </tr> 
<tr align="left"> <td align="center"> 4 </td> 
 <td > 4 </td> 
<td > DBA101 &nbsp;</td> 
<td > INTRODUCTION TO BUSINESS &nbsp;</td> 
<td > B &nbsp;</td> 
 </tr> 
<tr align="left"> <td align="center"> 5 </td> 
 <td > 5 </td> 
<td > DFI103 &nbsp;</td> 
<td > PRINCIPLES OF MICRO-ECONOMICS &nbsp;</td> 
<td > C &nbsp;</td> 
 </tr> 
<tr align="left"> <td align="center"> 6 </td> 
 <td > 6 </td> 
<td > DMS111 &nbsp;</td> 
<td > QUANTITATIVE METHODS FOR BUSINESS &nbsp;</td> 
<td > B &nbsp;</td> 
 </tr> 
</table>
</td> </tr> 
</table>
</p>	</div>
</div>
<div id="footer">
    <p class="right">&copy; 2013 <a href="https://www.uonbi.ac.ke/"> University of Nairobi</a> . Design: by
        <a href="https://smis.uonbi.ac.ke/index.php" title="ICT Centre">ICT Centre
        </a></p>
    <p><a href="https://www.uonbi.ac.ke/">About Us</a> &middot; </p>
</div>

<div id="footer">
    <p><font color="green">
            <ul>GOVERNMENT-SPONSORED (MODULE I) STUDENTS PAYMENT INSTRUCTIONS</ul>
        </font></p>
    <p style="font-weight: bold;">Pay to your respective college account</p>

    <p><font color="blue">
            <ul>SELF-SPONSORED PROGRAMMES (MODULE II) PAYMENT INSTRUCTIONS / OPTIONS</ul>
        </font></p>
		<b>1. Bank Account</b><BR>
		=> Cash Deposits, EFT or RTGS transfer to UON CESSP Collection Account No. <b>2032771362</b> at Barclays Bank, Plaza Branch<BR>
		=> Cash Deposits, EFT or RTGS transfer to UON CESSP US$ Dollar Account No. <b>2032770625</b> at Barclays Bank, Plaza Branch<BR>
      
		<b>2. M-Pesa Pay Bill </b><BR>
		=> The Business Number is <b>300059</b><BR>
		=> The Account Number is your <b>"Student Registration Number"</b> (or <b>"Admission Ref Number"</b> for new student) <BR>
        
		<b><font color = "red">*NOTE: CASH, AGENCY BANKING AND ATM DEPOSITS ARE NOT ALLOWED*</font></b>

    </p>

</div>


</div>
</body>
</html>

Como classificar array pela chave e pelo valor, sem perder o valor original da chave?

php

<?php

$array = array
(
 71 => 100,
 70 => 100,
 69 => 23.53,
 68 => 74.07,
 67 => 23.29,
 66 => 61.01,
 59 => 100,
 3 => 35,
 1 => 56.18
);
echo "<pre>";
var_export($array);
asort($array);
var_export(array_reverse($array, true));

Execute PHP Online

php

<?php
$start="07:00:00";
$end="17:00:00";

$b=array(
    array('start'=>"07:00:00",'end'=>'07:30:00'),
    array('start'=>"08:45:00",'end'=>'09:00:00'),
    array('start'=>"10:00:00",'end'=>'10:15:00'),
    
);

$sp=array();
$loop=$start;
while($loop <= $end) {
   
	array_push($sp,$loop);
	$loop=date('H:i:s',strtotime('+15 minute',strtotime($loop)));
}

for($i=0;$i<count($b);$i++){
    $loop =	$b[$i]['start'];
	$app15array=array();
	while($loop <= $b[$i]['end']) {
		array_push($app15array,$loop);
		$loop=date('H:i:s',strtotime('+15 minute',strtotime($loop)));
	}
    $minus=$app15array;
    print_r($minus);
    //***************
    $loop=$minus[0];
    $tmp= (count($minus));
    var_dump((string)$tmp);
    while($loop <= $minus[2]){
        echo "yes";
        if(count($minus)==2){
            if(in_array($minus[0],$sp,TRUE)){
                array_splice($sp, array_search($minus[0],$sp), 1);
            }
        }
        if(count($minus)==3){
            if(in_array($minus[0],$sp,TRUE)){
                array_splice($sp, array_search($minus[0],$sp), 2);
            }
        }
        $loop=date('H:i:s',strtotime('+15 minute',strtotime($loop)));
    }
    //****************
}
echo "<pre>";
print_r($sp);

image_hours

php

<?php
	date_default_timezone_set('Europe/Moscow');
	$h = date('H');
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		body{
			min-height: 100vh;
			background: url(img/img_dz/<?php echo floor($h / 6); ?>.jpg) no-repeat fixed;
			background-color: cover;
		}
	</style>
</head>
<body>
	<h1><?php echo $h; ?></h1>
</body>
</html>

https://pt.stackoverflow.com/q/359565/101

php

<?php
$f = function() {
    echo "OK";
};

echo get_class($f);

//https://pt.stackoverflow.com/q/359565/101

https://pt.stackoverflow.com/q/45323/101

php

<?php
$array_banco = array(array('field' => 'data', 'description' => 'Data cadastro'),
                     array('field' => 'ndereco', 'description' => 'Endereco')
);
foreach($array_banco as $item){
    $fields[$item['field']] = $item['description'];
}
var_dump($fields);

//https://pt.stackoverflow.com/q/45323/101

dates

php

<?php

$date="01-02-2019";
$month_timestamp = strtotime($date);
echo $month_timestamp;
if(date("W", $month_timestamp)==1)
{
	$kbd1_month_num="01";
}
else
{
	// We need to find the monday of the week to assign the kbd1 to the right month
	$kbd1_month_num=date('m', strtotime(date("o", $month_timestamp).'-W'.date("W", $month_timestamp)));
}
$kbd1_year_num=date("o", $month_timestamp);
echo "<br/>";
echo "Week:".date("W", $month_timestamp);
echo "<br/>";
echo "Month:".$kbd1_month_num;
echo "<br/>";
echo "Year:".$kbd1_year_num;

test

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
   echo "<h1>Hello, PHP!</h1>\n";
?>
</body>
</html>

Previous 1 ... 3 4 5 6 7 8 9 ... 103 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.