アニメ!アニメ!

2022年3月30日水曜日

WindowsAPI メッセージボックス

#include int WINAPI WinMain( HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { MessageBox(NULL , TEXT("Kitty on your lap") , TEXT("メッセージボックス") , MB_OK); return 0; } http://wisdom.sakura.ne.jp/system/winapi/win32/win5.html

PHP 変数の返り値

PHP 可変長引数

PHP 配列

 <?php


$moreScores = [

  55,

  72,

  'perfect',

  [90, 42, 88],

];


$scores = [

  90,

  40,

  ...$moreScores,

  100,

];


// print_r($scores);


echo $scores[5][2] . PHP_EOL;

2022年3月28日月曜日

PHP foreach

 <?php


$scores = [

  'first'  => 90, 

  'second' => 40, 

  'third'  => 100,

];


// foreach ($scores as $value) {

// foreach ($scores as $score) {

//   echo $score . PHP_EOL;

// }


foreach ($scores as $key => $score) {

  echo $key . ' - ' . $score . PHP_EOL;

}

2022年3月26日土曜日

PHP 配列

 <?php


$scores = [

  'first'  => 90, 

  'second' => 40, 

  'third'  => 100,

];


// var_dump($scores);

// print_r($scores);


echo $scores['third'] . PHP_EOL;

2022年3月24日木曜日

PHP 配列

 <?php


// $score1 = 90;

// $socre2 = 40;

// $score3 = 100;


$scores = [

  90,

  40,

  100,

];


$scores[1] = 60;

echo $scores[1] . PHP_EOL;

2022年3月21日月曜日

PHP null

 ~ $ php main.php

Gold Medal


Fatal error: Uncaught TypeError: Return value of getAward() must be of the type string, null returned in /home/dotinstall/main.php:7

Stack trace:

#0 /home/dotinstall/main.php(11): getAward(40)

#1 {main}

  thrown in /home/dotinstall/main.php on line 7

~ $ php main.php

Gold Medal


~ $ php main.php

Gold Medal


~ $ 



<?php


declare(strict_types=1);


function getAward(?int $score): ?string

{

  return $score >= 100 ? 'Gold Medal' : null;

}


echo getAward(150) .PHP_EOL;

echo getAward(40) .PHP_EOL;

2022年3月18日金曜日

PHP 引数の型

 <?php


declare(strict_types=1);


function showInfo(string $name, int $score): void

{

  echo $name . ': ' . $score . PHP_EOL;

}


// showInfo('taguchi', 40);

// showInfo('taguchi', 'dotinstall');

showInfo('taguchi', '4');


2022年3月17日木曜日

PHP 条件演算子

 <?php


function sum($a, $b, $c) 

{

  $total = $a + $b + $c;

  

  // if($total < 0){

  //   return 0;

  // }else{

  //   return $total;

  // }

  return $total < 0 ? 0 : $total;

}


echo sum(100, 300, 500) .PHP_EOL; //900

echo sum(-1000, 300, 500) .PHP_EOL; //0

PHP 無名関数

 <?php


// function sum($a, $b, $c)

// {

//   return $a + $b + $c;

// }


$sum = function ($a, $b, $c){ //無名関数

  return $a + $b + $c;

};


echo $sum(100, 300, 500) .PHP_EOL;

2022年3月16日水曜日

PHP スコープ

 <?php


$rate = 1.1; //グローバルスコープ


function sum($a, $b, $c)

{

  // global $rate;

  $rate = 1.08; //ローカルスコープ

  return ($a + $b + $c) * $rate;

}


echo sum(100, 200, 300) + sum(300, 400, 500) . PHP_EOL; //1944

2022年3月15日火曜日

PHP return

 <?php


function sum($a, $b, $c)

{

  // echo $a + $b + $c . PHP_EOL;

   return $a + $b + $c;

   echo 'Here!' .PHP_EOL;

}


sum(100, 200, 300);//600

sum(300, 400, 500);//1200


echo sum(100, 200, 300) + sum(300, 400, 500) .PHP_EOL;//1800

2022年3月14日月曜日

PHP 引数

 <?php


function showAd($message = 'Ad') //仮引数

{

  echo '----------' . PHP_EOL;

  echo '--- ' . $message . ' ---' . PHP_EOL;

  echo '----------' . PHP_EOL;

}


showAd('Header Ad'); //実引数

echo 'Tom is great!' . PHP_EOL;

echo 'Bob is great!' . PHP_EOL;

// showAd('Ad');

showAd();

echo 'Steve is great!' . PHP_EOL;

echo 'Bob is great!' . PHP_EOL;

showAd('Footer Ad');


MSB8020 v142 (プラットフォーム ツールセット = 'v142') のビルド ツールが見つかりません。

 https://scrapbox.io/gosyujin/MSB8020_v142_(%E3%83%97%E3%83%A9%E3%83%83%E3%83%88%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0_%E3%83%84%E3%83%BC%E3%83%AB%E3%82%BB%E3%83%83%E3%83%88_=_'v142')_%E3%81%AE%E3%83%93%E3%83%AB%E3%83%89_%E3%83%84%E3%83%BC%E3%83%AB%E3%81%8C%E8%A6%8B%E3%81%A4%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82

PHP 関数

 <?php


function showAd()

{

  echo '----------' .PHP_EOL;

  echo '--- Ad ---' . PHP_EOL;

  echo '----------' .PHP_EOL;

}


showAd();

echo 'Tom is great!' . PHP_EOL;

echo 'Bob is great!' . PHP_EOL;

showAd();

echo 'Steve is great!' . PHP_EOL;

echo 'Bob is great!' . PHP_EOL;

showAd();