Context Options and Parameters Flashcards
How are contexts created?
stream_context_create()
How are context options set?
stream_context_set_option()
How are context parameters set?
stream_context_set_params()
What are the 7 context options?
socket, HTTP, FTP, SSL, CURL, Phar, MongoDB
What are socket context options available for?
All wrappers that work over sockets, like tcp, http, and ftp.
What are the socket context options?
bindto - used to specify the IP address and/or the port number that PHP will use to access the network. The syntax is ip:port for IPv4 addresses, and [ip]:port for IPv6 addresses. Setting the IP or the port to 0 will let the system choose the IP and/or port.
backlog - used to limit the number of outstanding connections in the socket’s listen queue. This is only applicable to stream_socket_server().
Why can’t the port number for an FTP connection be specified with bindto?
Because FTP creates two socket connections during normal operation.
What are the HTTP context options?
method, header, user_agent, content, proxy, request_fulluri, follow_location, max_redirects, protocol_version, timeout, ignore_errors
What are the FTP context options?
overwrite - allow overwriting of existing files on server
resume_pos - file offset at which to begin transfer
proxy - proxy FTP request via http proxy server
When are CURL context options available?
When the CURL extension was compiled using the –with-curlwrappers configure option.
What are the CURL context options?
method, header, user_agent, content, proxy, max_redirects, curl_verify_ssl_host, curl_verify_ssl_peer,
What are the Phar context options?
compress - one of the Phar compression constants
metadata - Phar metadata
What parameter can be set on a context using the stream_context_set_params() function?
notification - a callable to be called when an event occurs on a stream.
How do you register custom stream wrappers?
With the stream_wrapper_register() function.
What URL syntax is supported to describe a wrapper?
Only scheme://
scheme:/ and scheme: syntaxes are not supported.
What are the supported URL-style protocols?
file://, http://, ftp://, php:// (for accessing various I/O streams), zlib:// (compression streams), data://, glob://, phar://, ssh2://, rar://, ogg://, expect:// (process interaction systems)
What is the default wrapper used with PHP?
file://
It represents the local filesystem.
When using the CLI sapi, to what directory does file:// default?
The directory from which the script was called.