본문 바로가기
PHP

내장함수, number, update

by 영감은어디에 2024. 10. 10.

number

  <b>Round:</b>                     
  <?= round(9876.54321) ?><br>
  <b>Round to 2</b> 
  <?= round(9876.54321, 2) ?><br>
  <b>Round half up:</b>             
  <?= round(1.5, 0, PHP_ROUND_HALF_UP) ?><br>
  <b>Round half down:</b>           
  <?= round(1.5, 0, PHP_ROUND_HALF_DOWN) ?><br>
  <b>ceil</b>                  
  <?= ceil(1.23) ?><br>
  <b>floor</b>                
  <?= floor(1.23) ?><br>
  <b>mt_rand</b>             
  <?= mt_rand(0, 10) ?><br>
  <b>제곱근</b>               
  <?= pow(4, 5) ?><br>
  <b>스퀘어</b>               
  <?= sqrt(16) ?><br>
  <b>Is a number: ture/false</b>               
  <?= is_numeric(123) ?><br>
  <b> number_format(12345.6789, 2, '.', ',')</b>             
  <?= number_format(12345.6789, 2, '.', ',') ?><br>

update

<?php

$order = ['notebook', 'pencil', 'eraser',];
array_unshift($order, 'scissors'); // Add to start
array_pop($order);                 // Remove last
$items = implode(', ', $order);    // Convert to string

$classes = ['Patchwork' => 'April 12th',
            'Knitting'  => 'May 4th',
            'Lettering' => 'May 18th',];
array_shift($classes);                   // Remove 1st
$new     = ['Origami'  => 'June 5th',
            'Quilting' => 'June 23rd',]; // New items
$classes = array_merge($classes, $new);  // Add to end
?>
<?php include 'includes/header.php'; ?>

<h1>Order</h1>
<?= $items ?>
<h1>Classes</h1>
<?php foreach($classes as $description => $date) { ?>
  <b><?= $description ?></b> <?= $date ?><br>
<?php } ?>

파일정보

<?php
$path = 'img/logo.png';
?>

<?php if (file_exists($path)) { ?>
  <b>Name:</b>      <?= pathinfo($path, PATHINFO_BASENAME) ?><br>
  <b>Size:</b>      <?= filesize($path) ?> bytes<br>
  <b>Mime type:</b> <?= mime_content_type($path) ?><br>
  <b>Folder:</b>    <?= pathinfo($path, PATHINFO_DIRNAME) ?><br>
<?php } else { ?>
  <p>There is no such file.</p>
<?php } ?>

'PHP' 카테고리의 다른 글

sql  (0) 2024.10.11
date  (0) 2024.10.10
image file  (0) 2024.10.10
form  (0) 2024.10.10
object  (0) 2024.10.09
function  (0) 2024.10.09
foreach  (0) 2024.10.09
PC에 XAMPP용 Imagick, ImageMagick 설치 하는법  (0) 2024.06.27