CakeFest 2024: The Official CakePHP Conference

shmop_close

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

shmop_close共有メモリブロックを閉じる

警告

この関数は PHP 8.0.0 で 非推奨になります。この関数に頼らないことを強く推奨します。

説明

shmop_close(Shmop $shmop): void

注意:

この関数を実行しても何も起こりません。PHP 8.0.0 より前のバージョンでは、この関数はリソースを閉じるのに使われていました。

shmop_close() は、共有メモリブロックを閉じます。

パラメータ

shmop

shmop_open() 関数で作られた共有メモリブロックのリソース。

戻り値

値を返しません。

変更履歴

バージョン 説明
8.0.0 引数 shmop は、 Shmop クラスのインスタンスを期待するようになりました。 これより前のバージョンでは、リソースが期待されていました。

例1 共有メモリブロックを閉じる

<?php
shmop_close
($shm_id);
?>

この例は、$shm_id で識別される共有メモリブロックを閉じます。

参考

  • shmop_open() - 共有メモリブロックを作成またはオープンする

add a note

User Contributed Notes 2 notes

up
3
slavapl at mailandnews dot com
22 years ago
shmop_close doesn't delete the memory segment, it just detaches from it.

If you have created the block and need to delete it you must call shmop_delete **BEFORE** calling shmop_close (for reasons outlined in shmop_delete help page notes).
up
1
shortboi
2 years ago
As explained on this page, PHP 8.0.0 expects a Shmop instance instead of a resource. According to bug #81098 this change means that the Shmop closes itself when the script completes so there is no need to close it with shmop_close.

Using function_exists('shmop_close') will return true but calling shmop_close will throw a deprecation error.

The documentation explains the change in 8.0.0 expects the expected argument changed without mentioning it'll just throw a deprecation error.
To Top