update page now

Uri\WhatWg\Url::withPort

(PHP 8 >= 8.5.0)

Uri\WhatWg\Url::withPortModifica el componente de puerto

Descripción

public Uri\WhatWg\Url::withPort(?int $port): static

Crea una nueva URL y modifica su componente de puerto.

Parámetros

port
Nuevo componente de puerto.

Valores devueltos

La instancia de Uri\WhatWg\Url modificada.

Errores/Excepciones

Si la URL resultante es inválida, se lanza una excepción Uri\WhatWg\InvalidUrlException.

Ejemplos

Ejemplo #1 Ejemplo básico de Uri\WhatWg\Url::withPort()

<?php
$url
= new \Uri\WhatWg\Url("https://example.com:8080");
$url = $url->withPort(443);

echo
$url->getPort();
?>

El ejemplo anterior mostrará:

443

Ver también

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top