<?php
class Net
{
public static function netMask($cidr)
{
$ipc = explode('/', $cidr);
$ip = $ipc[0];
$bc = $ipc[1];
$netmask = str_split(str_pad(str_pad('', $bc, '1'), 32, '0'), 8);
foreach ($netmask as &$element) {
$element = bindec($element);
}
return array($ip, join('.', $netmask));
}
}
print_r(Net::netMask('84.22.142.192/27'));
// Выхлоп:
// Array
// (
// [0] => 84.22.142.192
// [1] => 255.255.255.224
// )
<?php
$m_1 = array("d", "b", "g", "v", "z", "j", "r", "l", "m", "n", "h", "c", "t", "p", "k", "f", "s");
$m_2 = array("a", "o", "e", "u", "i");
$key1 = array_rand($m_1, 1);
$key2 = array_rand($m_2, 1);
for ($i = 0; $i < 3; $i++) {
echo $m_1[$key1] . $m_2[$key2];
}
<?php
$m_1 = array("d", "b", "g", "v", "z", "j", "r", "l", "m", "n", "h", "c", "t", "p", "k", "f", "s");
$m_2 = array("a", "o", "e", "u", "i");
$key1 = array_rand($m_1, 3);
$key2 = array_rand($m_2, 3);
for ($i = 0; $i < 3; $i++) {
$phrase .= $m_1[$key1[$i]] . $m_2[$key2[$i]];
}
echo $phrase;
<?php if ( is_front_page() ) : ?>
<div class="header-page clearfix">
<h2 class="name-page">Акции</h2><a href="#" class="cart-btn">
<div class="cart-btn__img"><img src=" <?php echo esc_url( get_template_directory_uri() );?>/img/shopping-bag.svg" alt=""></div>
<div class="cart-btn__text">Ваша корзина</div></a>
</div>
<?php else: ?>
<div>AAAAAAAAAAAAAAAA</div>
<?php endif; ?>
<button onclick="javascript:document.location.href='yourfile.php?file=text.txt'">Button</button>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="source.js"></script>
</head>
<body>
<form action="" method="post"> <!-- метод POST или GET отпрака через форму без JS -->
<input type="submit" name="btn" value="file1">
<input type="submit" name="btn" value="file2">
</form>
<button id ="a">btnjs1</button> <!-- Кнопки к которым привязан JS -->
<button id= "b">btnjs2</button>
</body>
</html>
<?php
if (isset($_POST['btn'])){ // получаем переменную которую посылали через форму
$action = $_POST['btn'];
switch ($action) {
case 'file1' : $file_post = 'file1.txt'; break;
case 'file2' : $file_post = 'file2.txt'; break;
};
} else {
$file_post ='file1.txt';
};
if (isset($_GET['file'])){ // получаем переменную которую отсылали через JS
$file_get = $_GET['file'];
} else {
$file_get = 'file2.txt';
};
$files_post = file($file_post);
echo "<p>Text area with POST from PHP</p>";
echo '<textarea rows="10" cols="45">';
foreach ($files_post as $line) {echo $line;}
echo '</textarea>';
$files_get = file($file_get);
echo "<p>Text area with GET from JS</p>";
echo '<textarea rows="10" cols="45">';
foreach ($files_get as $line) {echo $line;}
echo '</textarea>';
?>
//;$(function(){
// $("#a").click(function(){
// $(location).attr("href", "index.php?file=file1.txt");
// });
// $("#b").click(function(){
// $(location).attr("href", "index.php?file=file2.txt");
// });
//});
;document.addEventListener("DOMContentLoaded", function(event){
document.getElementById('a').onclick = function (){
document.location.href = 'index.php?file=file1.txt';
};
document.getElementById('b').onclick = function (){
document.location.href = 'index.php?file=file2.txt';
};
});