首页 \ 问答 \ 如何评论包含* /的字符串(How to comment a string containing */)

如何评论包含* /的字符串(How to comment a string containing */)

我有一行PHP源代码我希望将其保存在PHP文件中作为注释,因此可以在必要时使用它。 这只是一个调试脚本,因此保持文件清洁不是问题。

不过,我试图用/**/来评论这些行:

/*
$path = FOLDER . "*/*/*/*/*.gif";
$files = glob($path);
*/

但这会导致解析错误,因为路径*/*/*/关闭注释块。 开头/*不会被视为字符串中的开头注释,但由于未解析注释代码, */被视为结束注释。

任何人都可以在不使用//情况下想到解决方法?


I have a line of PHP source code I would like to keep in a PHP file as a comment, so it can be used when necessary. This is only a debugging script, so keeping the file clean is not an issue.

Nevertheless, I am trying to comment these lines using /* and */:

/*
$path = FOLDER . "*/*/*/*/*.gif";
$files = glob($path);
*/

But this result in a parse error, because the path */*/*/ closes the comment block. An opening /* won't be treated as an opening comment inside a string, but since the commented code is not parsed, the */ is treated as a closing comment.

Can anyone can think of a workaround without using //?


原文:https://stackoverflow.com/questions/10626229
更新时间:2021-11-27 06:11

最满意答案

最简单的解决方法是在IB中创建虚拟标签,为文本提供您喜欢的颜色并设置为隐藏。 然后,您可以在代码中引用此颜色,将标签设置为所需的颜色。

yourLabel.textColor = hiddenLabel.textColor

以编程方式更改文本颜色的唯一方法是使用标准颜色, UIColor.whiteUIColor.green ...


The easiest workaround is create dummy labels in IB, give them the text the color you like and set to hidden. You can then reference this color in your code to set your label to the desired color.

yourLabel.textColor = hiddenLabel.textColor

The only way I could change the text color programmatically was by using the standard colors, UIColor.white, UIColor.green...

相关问答

更多
  • 只需键入它。它编译。 UILabel.appearance().textColor = .red Just type it in. It compiles. UILabel.appearance().textColor = .red
  • textColour属性没有被指定为在文档中是动画的,所以我不认为你可以使用一个简单的UIView动画块来实现... 这可能是相当粗暴地完成, NSTimer每几毫秒发射一次,每次逐渐将颜色逐个设置为另一个。 我说这是粗糙的,因为它需要一个数组或一些其他容器的预设颜色值从起始颜色到完成颜色,我敢肯定有一种方法,你可以使用核心动画或东西,我只是不知道是什么 The textColor property is not specified as being animatable in the docs, so I ...
  • 最简单的解决方法是在IB中创建虚拟标签,为文本提供您喜欢的颜色并设置为隐藏。 然后,您可以在代码中引用此颜色,将标签设置为所需的颜色。 yourLabel.textColor = hiddenLabel.textColor 以编程方式更改文本颜色的唯一方法是使用标准颜色, UIColor.white , UIColor.green ... The easiest workaround is create dummy labels in IB, give them the text the color yo ...
  • 这些现在是enum 。 你可以做: label.textAlignment = NSTextAlignment.Center; 或者,简写为: label.textAlignment = .Center; Swift 3 label.textAlignment = .center These are now enums. You can do: label.textAlignment = NSTextAlignment.center; Or, for shorthand: label.textAli ...
  • 在您的ViewController上删除该行 self.codeText.delegate = self 您不能指定类型“ViewController”的值来键入“UITextViewDelegate?” codeText.textColor = UIColor.redColor() 工作得很好。 I ended up deleting the UITextField in the Storyboard and putting a new one. I connected it to the ViewC ...
  • 或者利用Swift 4的新键值观察技能,不需要UILabel的扩展 创建一个属性 var textColorObservation : NSKeyValueObservation? 和观察者 textColorObservation = labelValue.observe(\.text, options: [.new]) { (label, change) in guard let text = change.newValue!, let doubleValue = Double(text) ...
  • 看起来您正在修改一次showAbout实例,然后将另一个实例添加为子视图。 发生这种情况是因为showAbout是“计算属性” 。 计算属性实际上并不存储值,而是在每次调用时计算值(如函数)。 您可以通过在showAbout的主体中设置断点来验证此行为,并注意它被调用两次。 因此,在调用initializeViews时 showAbout.layer.mask = showAboutMask 您计算一个UILabel实例并修改其图层的掩码。 然后,当你打电话 addSubview(showAbout) ...
  • 您无法访问代码中标签的原因是您没有标签与代码的连接,只需在默认的UITableViewCell上添加标签就行不通。 我想你正在使用自定义的UITableViewCell? 如果没有,那么使用自定义单元格并在代码中添加三个标签,并在UI上将它们作为插座连接,在代码中,您可以使用cell.label1等访问它们 class CustomTableViewCell: UITableViewCell { @IBOutlet var label1:UILabel! @IBOutl ...
  • 这两行是自动计算单元高度所必需的。 把它们放在viewDidLoad中。 self.tableView.estimatedRowHeight = 50.0 self.tableView.rowHeight = UITableViewAutomaticDimension Finally I was able to make my multiline UILabel adding this code: self.tableView.estimatedRowHeight = 50.0 and reducing ...
  • UILabel.textColor不支持动画。 但您可以为CATextLayer制作动画: 斯威夫特 : let textLayer = CATextLayer() textLayer.string = "Your text" textLayer.foregroundColor = yourFirstColor textLayer.frame = yourButton.bounds yourButton.layer.addSublayer(textLayer) UIView.animateWithDura ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)