Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Return a formatted string
<?php sprintf(string $format, mixed ...$values): string
<?php public static function new(string $name): self
{
return new self(
sprintf('Named parameter "%s" does not have a bound value.', $name)
);
}
}
<?php public static function new(int $index): self
{
return new self(
sprintf('Positional parameter at index %d does not have a bound value.', $index)
);
}
}
<?php continue;
}
$chunks[] = sprintf('(%s=%s)', $key, $string);
}
return implode('', $chunks);
<?php public static function new($type): self
{
return new self(sprintf('Unknown parameter type, %d given.', $type));
}
}
<?php $chunks = [];
foreach ($params as $key => $value) {
$chunks[] = sprintf('%s=%s', $key, $value);
}
return new self(implode(';', $chunks));
<?php {
public static function new(int $parameter): self
{
return new self(sprintf('Failed reading the stream resource for parameter #%d.', $parameter));
}
}
<?php public static function fromCharset(mysqli $connection, string $charset): self
{
return new self(
sprintf('Failed to set charset "%s": %s', $charset, $connection->error),
$connection->sqlstate,
$connection->errno
);
<?php public static function fromOption(int $option, $value): self
{
return new self(
sprintf('Failed to set option %d with value "%s"', $option, $value)
);
}
}
<?php public static function new(int $parameter): self
{
return new self(
sprintf('The resource passed as a LARGE_OBJECT parameter #%d must be of type "stream"', $parameter)
);
}
}
<?php public static function new(int $offset): self
{
return new self(
sprintf(
'The statement contains non-terminated string literal starting at offset %d.',
$offset
)
);
}
}
<?php public static function new(int $index): self
{
return new self(
sprintf('Could not find variable mapping with index %d, in the SQL statement', $index)
);
}
}
<?php $connectionOptionsDsn = '';
foreach ($connectionOptions as $paramName => $paramValue) {
$connectionOptionsDsn .= sprintf(';%s=%s', $paramName, $paramValue);
}
return $connectionOptionsDsn;
<?php }
if (is_float($value)) {
return sprintf('%F', $value);
}
return "'" . str_replace("'", "''", $value) . "'";
<?php {
public static function notSupported(string $method): self
{
return new self(sprintf("Operation '%s' is not supported by platform.", $method));
}
<?php {
if (is_object($invalidPlatform)) {
return new self(
sprintf(
"Option 'platform' must be a subtype of '%s', instance of '%s' given",
AbstractPlatform::class,
get_class($invalidPlatform)
)
);
}