3v4l.org

run code in 300+ PHP versions simultaneously
<?php #ここでドメイン名を指定 $domain_name = 'yahoo.co.jp'; #外部接続するために必要なストリームコンテキストを取得する(ここでアロー演算子でSSL証明書の情報を絞り混んでます) $stream_context = stream_context_create(array( 'ssl' => array('capture_peer_cert' => true) )); #stream_socket_client関数で外物接続。$errno は接続失敗時のシステムエラーのレベルが #$errstrは接続失敗した時のエラーメッセージが入ります 5 と書いてあるところはタイムアウトまでの時間です $resource = stream_socket_client( 'ssl://' . $domain_name . ':443',$errno,$errstr,5,STREAM_CLIENT_CONNECT,$stream_context ); #帰ってきた情報からstream_context_get_paramsで選んだドメインの情報を配列で取得します $cont = stream_context_get_params($resource); #上記で撮ってきた配列から配列からpeer_certificateという場所から idを取得してそれから全情報を取得する。 $parsed = openssl_x509_parse($cont['options']['ssl']['peer_certificate']); #あとは全情報から配列を抜き出して絞り込んで好きな形式に期限を出す if(strpos($parsed['subject']['CN'], $domain_name) !== false){ echo date('Y/m/d', $parsed['validTo_time_t']); }else{ echo 'not contract.'; }
Output for git.master, git.master_jit
Warning: stream_socket_client(): Unable to connect to ssl://yahoo.co.jp:443 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in /in/9au6Z on line 10 Fatal error: Uncaught TypeError: stream_context_get_params(): Argument #1 ($context) must be of type resource, bool given in /in/9au6Z:14 Stack trace: #0 /in/9au6Z(14): stream_context_get_params(false) #1 {main} thrown in /in/9au6Z on line 14
Process exited with code 255.
Output for rfc.property-hooks
Warning: stream_socket_client(): Unable to connect to ssl://yahoo.co.jp:443 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in /in/9au6Z on line 10 Fatal error: Uncaught TypeError: stream_context_get_params(): Argument #1 ($context) must be of type resource, false given in /in/9au6Z:14 Stack trace: #0 /in/9au6Z(14): stream_context_get_params(false) #1 {main} thrown in /in/9au6Z on line 14
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
162.02 ms | 407 KiB | 5 Q