<?php
require_once 'vendor/connect.php';
$login = mysqli_real_escape_string($connect, $_SESSION["login"]);
$query = mysqli_query($connect, "SELECT * FROM `users` WHERE login = '$login'");
$balance = mysqli_fetch_assoc($query);
echo 'Balance:' . $balance['balance']. PHP_EOL;
if(isset($_POST['click'])) {
mysqli_query($connect, "UPDATE `users` SET `balance`=`balance`+0.001 WHERE login = '$login'");
echo 'New balance:' . ($balance['balance'] + 0.001) . PHP_EOL;
}
?>
<?php
require_once 'vendor/connect.php';
/* prepare statement */
$stmt = $connect->prepare("SELECT `balance` FROM `users` WHERE login = ? ");
/* bind parameters for login */
$stmt->bind_param("s", $_SESSION["login"]);
/* execute query */
$stmt->execute();
$stmt->bind_result($balance);
/* fetch value */
$stmt->fetch();
/* free result to next use */
$stmt->free_result();
echo 'Balance:' . $balance . PHP_EOL;
if (isset($_POST['click'])) {
/* prepare statement */
$stmt = $connect->prepare("UPDATE `users` SET `balance`=`balance`+0.001 WHERE login = ? ");
/* bind parameters for login */
$stmt->bind_param("s", $_SESSION["login"]);
/* execute query */
$stmt->execute();
echo 'New balance:' . ($balance['balance'] + 0.001) . PHP_EOL;
}
?>
select C.Id
from News N
join Categories_Of_News CoN on CoN.News_Id = N.Id
join Category C on C.Id = CoN.Category_Id
where N.Id = :news_id
$items = [
'school_table' => [
'name' => 'School Table',
'price' => 100
],
'school_chair' => [
'name' => 'School Chair',
'price' => 50
]
];
$item = $items[ 'school_table'];
echo $item['name'] . ' for ' . $item['price'] . ' money';
<?php
declare(strict_types=1);
class Ellipsis
{
private string $char;
private int $count;
/**
* @param string $char
* @param int $count
*/
public function __construct(string $char, int $count)
{
$this->char = $char;
$this->count = $count;
}
/**
* @return string
*/
public function getChar(): string
{
return $this->char;
}
/**
* @return int
*/
public function getCount(): int
{
return $this->count;
}
}
class Ellipsisist
{
private Ellipsis $ellipsis;
/**
* @param Ellipsis $ellipsis
*/
public function __construct(Ellipsis $ellipsis)
{
$this->ellipsis = $ellipsis;
}
/**
* @param string $value
* @return string
*/
public function __invoke(string $value): string
{
return str_pad($value, mb_strlen($value) + $this->ellipsis->getCount(), $this->ellipsis->getChar(), STR_PAD_LEFT);
}
}
class EllipsisistFactory
{
/**
* @param string $char
* @param int $count
* @return Ellipsisist
*/
public static function make(string $char, int $count): Ellipsisist
{
return new Ellipsisist(new Ellipsis($char, $count));
}
}
$arr = ['foo', 'bar', 'baz'];
$ellipsisiatedArr = array_map(
EllipsisistFactory::make('.', 3),
$arr
);
var_dump($ellipsisiatedArr);
И вопрос на засыпку, какой вообще является работа на дистанционке за рубежом? Чисто черной? или договор присылают как-то почтой?
abstract class Controller extends AbstractController
{
public static function getSubscribedServices()
{
return array_merge(parent::getSubscribedServices(), [
'setting' => Setting::class,
]);
}
protected function getSetting(): Setting
{
return $this->get('setting');
}
}
entryPoint
класс от AuthenticationEntryPointInterface
$security->firewall('main')
->lazy(true)
->customAuthenticators([LoginAuthenticator::class])
->entryPoint(AuthenticationEntryPoint::class)
->logout()
->path('logout')
->target('login');
<form id="form">
<div id="dii">
<input type="hidden" id="login" value="<? echo $login; ?>">
<button type="submit" id="" class="status" value="1">1</button>
<button type="submit" id="" class="status" value="2">2</button>
<button type="submit" id="" class="status" value="3">3</button>
<button type="submit" id="" class="status" value="4">4</button>
</div>
<div id="app" width="640" ></div>
</form>
$("#dii>button").on('click', function(e){
e.preventDefault();
var status = $(this).val();
console.log(status);
var login = document.getElementById('login').value;
$.ajax({
type: 'post',
url: 'preload.php',
data: {status: status, login: login},
success: function(data){
//alert("Ваше сообщение отпрвлено!");
alert(data);
$("#app").empty();
$("#app").append(data);
}
});
});
#button {
color: green;
width: 250px;
height: 60px;
}
#button2 {
color: green;
width: 250px;
height: 60px;
}
#button3 {
color: green;
width: 250px;
height: 60px;
}
#button4 {
color: green;
width: 250px;
height: 60px;
}
create table questionnaires (
id int primary key auto_increment,
title varchar(255)
);
create table questios (
id int primary key auto_increment,
questionnaire_id int,
title varchar(255),
foreign key (questionnaire_id) references questionnaires(id)
);
create table answers (
id int primary key auto_increment,
question_id int,
title varchar(255),
rigth bool,
foreign key (question_id) references questios(id)
);
class SimpleClass
{
public function __invoke()
{
return $this;
}
public function stdout($string)
{
echo $string;
return $this;
}
}
class SimpleClass
{
public function __invoke(string $string = PHP_EOL): self
{
echo $string;
return $this;
}
}