$table = '<h1>%s</h1>';
switch ($_GET['Guid']) {
case '0001':
echo sprintf($table, 'Exporter 1');
break;
case '0002':
echo sprintf($table, 'Exporter 2');;
break;
default:
echo "Wrong Guid";
break;
}
switch ($_GET['Guid']) {
case '0001':
$exportername = "Exporter 1";
break;
case '0002':
$exportername = "Exporter 2";
break;
default:
echo "Wrong Guid";
break;
}
echo $table = "<h1>" . $exportername . "</h1>";
$catalog_data = array_map(
function (array $array): array {
return [
'name' => $array['name'],
'url' => $array['url'],
];
},
array_unique($result["array"], SORT_REGULAR),
);
for ($i = 1; $i <=$str_pag; $i++) {
echo sprintf(' <a href=index.php?page=%d>%d</a> ', $i, $i);
}
if (mysqli_num_rows($query) == 0) {
echo 'There are no records!'; //одинарные кавычки, здесь двойные не нужны
} else {
array_map(
function (array $article): void {
echo sprintf(
'<div class="art">%d<a href=page.php?id=%d>%s</a><br>%s<br></div>',
$article['id'],
$article['id'],
$article['title'],
$article['text'],
);
},
mysqli_fetch_assoc($query),
);
}
class ItemsData
{
/**
* @var int
*/
private int $id;
/**
* @var string
*/
private string $name;
/**
* @param int $id
* @param string $name
*/
public function __construct(int $id, string $name)
{
$this->id = $id;
$this->name = $name;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
}
//а потом в методе
public function loadItems():array
{
$stmt = $this->db->prepare("SELECT `id`, `name` FROM `items`");
$stmt->execute();
$data = array_map(
fn (array $item): ItemsData => new ItemsData($item['id'],$item['name']),
$stmt->fetchAll(PDO::FETCH_ASSOC),
);
$stmt->closeCursor();
return $data;
}
public function jsonSerialize(): array {
return [
'id' => $this->getId(),
'name' => $this->getName(),
];
}
psr-4": {
"DarkDante\\ValidationBundle\\": ""
},
use DarkDante\ValidationBundle\Service\ValidationService;
class MyConstructor extends AbstractConsructor {
private ValidationService $validationService;
public function __construct(ValidationService $validationService)
{
$this->validationService = $validationService;
}
}
DarkDante\ValidationBundle\Service\ValidationService:
autowire: true
autoconfigure: true
DarkDante\ValidationBundle\Validation\Constraints\MyConstraint:
autowire: true
autoconfigure: true
Attempted to load class \"MyConstraint\" from namespace \"DarkDante\\ValidationBundle\\Validation\\Constraints\".\nDid you forget a \"use\" statement for another namespace?
use DarkDante\ValidationBundle\Validation\Constraints\MyConstraint;
DarkDante\ValidationBundle\Service\ValidationService:
autowire: true
autoconfigure: true
DarkDante\ValidationBundle\Validation\Constraints\MyConstraint:
autowire: true
autoconfigure: true
const File_NAME = 'file.php';
$content = file_get_content(FILE_NAME);
//какая то операция над контентом
file_put_content(FILE_NAME, $content);